Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Papademuchos
Creator
Creator

method is undefined for the type Struct error

I'm getting an error when using a Global Routine.

I created a custom routine with a simple method that takes in two String parameters and returns an int. I'm calling the routine.method in a tMap.

In Job # 1, I used it all over the place and it works as expected. No errors.

I moved on to Job # 2 and I get an error:

0695b00000OCtpxAAD.png 

When I hover over the NULL_Check routine, it doesn't show "Routines", it shows something different:

0695b00000OCtrUAAT.png 

In Job # 1 where it works, when I hover over the NULL_Check routine it shows "Routines" as expected:

0695b00000OCts8AAD.png 

Both jobs show "Import NULL_Check;" in the import section at the top.

I went in to Setup Codes Dependencies under Global Routines and made sure it was listed there. It's there in both jobs.

I don't understand why one jobs references the routine properly and the other job is reading it as a struct... and why it's trying to reference a tDBInput component.

Any ideas, thoughts, suggestions would be appreciated!

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Sorry about the delay, I've been trying to recreate this here. I *think* I might have found the problem. In your job, you have a row called NULL_Check. Can you change this to NULL_CheckRow.

 

Once you've done that, take a look at the code. Let me know what happens.

View solution in original post

7 Replies
Anonymous
Not applicable

Can you copy the code that fails and paste it here exactly as it's copied? Also, show where it is used in the job design (or tMap).

Papademuchos
Creator
Creator
Author

Sure! here are more screen shots and snippets of the code: (hopefully the screen shots are big enough)

 

The portion of my job - tMap "Plan_Type_Check" is where it's failing:

0695b00000OCu2XAAT.pngHere is the view inside the tMap. Note: I have inner join on a lookup source. The call to my method is in an output table with "Catch Inner Join Reject" set to Yes.

0695b00000OCu31AAD.pngHere is the Expression for my field that calls the method:

 

NULL_Check.check_source(Dates_Check.plan_type, "NULL") 

 

Here is the Routine and Method:

 

package routines;

 

public class NULL_Check {

 

   

  public static Integer check_source(String new_field, String NULL_Indicator) {

    if (new_field.equals(NULL_Indicator)) {

      return -1; //$NON-NLS-1$

    }

    if (new_field.equals("")) {

     return 0;

    }

    return null; //$NON-NLS-1$ //$NON-NLS-2$

  } 

}

 

Here is the portion of code that's failing:

 

{ // start of Var scope

 

// ###############################

// # Vars tables

 

Var__tMap_3__Struct Var = Var__tMap_3;// ###############################

// ###############################

// # Output tables

 

Plan_Type_Check = null;

Plan_Type_Check_List.clear();

Plan_Type_Errors = null;

 

if (!rejectedInnerJoin_tMap_3) {

 

// # Output table : 'Plan_Type_Check'

count_Plan_Type_Check_tMap_3++;

 

Plan_Type_Check_tmp.id = Dates_Check.id;

Plan_Type_Check_tmp.benefit_plan_code = Dates_Check.benefit_plan_code;

Plan_Type_Check_tmp.description = Dates_Check.description;

Plan_Type_Check_tmp.comment = Dates_Check.comment;

Plan_Type_Check_tmp.start_date = Dates_Check.start_date;

Plan_Type_Check_tmp.end_date = Dates_Check.end_date;

Plan_Type_Check_tmp.plan_type_id = plan_type_lookup.id;

Plan_Type_Check_tmp.line_of_business = Dates_Check.line_of_business;

Plan_Type_Check_tmp.load_date = Dates_Check.load_date;

Plan_Type_Check_List.add(Plan_Type_Check_tmp);

Plan_Type_Check = Plan_Type_Check_tmp;

log.debug("tMap_3 - Outputting the record " + count_Plan_Type_Check_tMap_3

+ " of the output table 'Plan_Type_Check'.");

 

} // closing inner join bracket (1)

// ###### START REJECTS ##### 

 

// # Output reject table : 'Invalid_State_0'

// # Filter conditions 

if (rejectedInnerJoin_tMap_3) {

Plan_Type_Check_tmp = new Plan_Type_CheckStruct();

 

Plan_Type_Check_tmp.id = Dates_Check.id;

Plan_Type_Check_tmp.benefit_plan_code = Dates_Check.benefit_plan_code;

Plan_Type_Check_tmp.description = Dates_Check.description;

Plan_Type_Check_tmp.comment = Dates_Check.comment;

Plan_Type_Check_tmp.start_date = Dates_Check.start_date;

Plan_Type_Check_tmp.end_date = Dates_Check.end_date;

Plan_Type_Check_tmp.plan_type_id = NULL_Check

.check_source(Dates_Check.plan_type, "NULL");

Plan_Type_Check_tmp.line_of_business = Dates_Check.line_of_business;

Plan_Type_Check_tmp.load_date = Dates_Check.load_date;

Plan_Type_Check_List.add(Plan_Type_Check_tmp);

Plan_Type_Check = Plan_Type_Check_tmp;

log.debug("tMap_3 - Outputting the record " + count_Plan_Type_Check_tMap_3

+ " of the output table 'Invalid_State_0'.");

 

} // closing filter/reject

 

Let me know if anything else would be helpful.

 

Anonymous
Not applicable

OK, this revealed to me what I suspected. If you look at this screenshot of me highlighting the code you sent me, you'll see a space after the NULL_Check ........

 

0695b00000OCuFWAA1.png 

I copied this as it was delivered and pasted it to a text analysis application (https://www.textmagic.com/free-tools/unicode-detector) and this is what it revealed.....

 

0695b00000OCuHNAA1.png 

I've seen this as a problem previously. Particularly when text is added to the tMap output column without clicking on the button and adding it in the expression window there. Can you test this? Open the expression window and re-write the expression.

 

Let me know how that works out.

 

Papademuchos
Creator
Creator
Author

Thanks for you time and help with this issue. When I go into the Expression I can see there is no space between "NULL_Check" and ".check_source". Here is the text copied directly from the Expression window and a screen shot:

 

NULL_Check.check_source(Dates_Check.plan_type, "NULL") 

 

0695b00000OCuYxAAL.png 

Also, I've been going into the Expression Builder and typing out NULL_Check. when I type in the period Intellisense gives the suggestions of my methods in this routine / class. I've been selecting "check_source" from the list and it drops it in for me. NOTE: The screen shot shows four other methods that I did not paste in my reply above... I was trying to keep the text short and only included the one method I'm working with here. 🙂

 

0695b00000OCua5AAD.png 

I also went back in to the code portion and confirmed there is no space at the end of the "NULL_Check"

 

0695b00000OCuckAAD.png 

Anonymous
Not applicable

Sorry about the delay, I've been trying to recreate this here. I *think* I might have found the problem. In your job, you have a row called NULL_Check. Can you change this to NULL_CheckRow.

 

Once you've done that, take a look at the code. Let me know what happens.

Papademuchos
Creator
Creator
Author

That was it! Thank you - I knew it had to be something simple. After changing my output "NULL_Check" to "NULL_Check_Row" I know no longer get the error. The "NULL_Check" is now properly recognized as a routine / method. Thanks again for your input.

Anonymous
Not applicable

No problem. This is because your NULL_Check row is actually the name of an object based on a NULL_CheckStrut class which is created for the row. So it clashes with the name of your routine.