Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:
When I hover over the NULL_Check routine, it doesn't show "Routines", it shows something different:
In Job # 1 where it works, when I hover over the NULL_Check routine it shows "Routines" as expected:
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!
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.
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).
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:
Here 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.
Here 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.
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 ........
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.....
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.
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")
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. 🙂
I also went back in to the code portion and confirmed there is no space at the end of the "NULL_Check"
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.
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.
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.