Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there ,
I have code something like below, I am trying to retrieve global variable values (saved in tsetglobalvar) based on the lookup values .
I have written javacode to separate each string value and trying to retrieve values from global variable based on the string value separated using java code .
//Code generated according to input schema and output schema
String str ;
String x=null;
/* below values coming from an API output */
output_row.ROW_ID = input_row.ROW_NUM;
output_row.JOB_ID = input_row.JOB_ID;
output_row.END_POINT = input_row.END_POINT;
output_row.STATUSCODE = input_row.STATUSCODE;
output_row.STRING = input_row.STRING;
output_row.BODY = input_row.BODY;
str=output_row.BODY;
/*java code to split string values */
String[] arrOfStr = str.split("\",\"");
for (String a : arrOfStr)
{
/* trying to assign value to x by retrieving value of a (extracted value of string ) if available using globalMap.get(a)
(This is erroring out )
*/if(x==null)
x=((String)globalMap.get(a));
else
x=x+","+
((String)globalMap.get(a))
;}
System.out.println(x);
output_row.Warnings=x;
can you guys please help me with the code to get the global variable value for "a" ?
Thanks & Regards,
Sudheendra
Hi
Can you share a screenshot of the job? Please show us where do you put the value to global variable.
Regards
Shong
Hi Shong,
Please find the screenshot attached ....please let me know if you need more details ...
the java code highligheted is where I have written this code
Thanks a lot for looking into this
From your screenshot, I think you always get the last value from the global variable, if you want to iterate each value, you need to use tFlowToIterate component, for example.
tHashInput--mainI(row1)--tFlowToIterate--iterate--tJava--oncomponentok--tMysqlInput--main--tJavaRow
on tJavaRow, you can retrieve value of global variable like:
String str ;
String x=null;
output_row.BODY = input_row.BODY;
str=output_row.BODY;
String[] arrOfStr = str.split("\",\"");
for (String a : arrOfStr)
{
if(x==null)
x=((String)globalMap.get(row1.columnName));
else
x=x+","+
((String)globalMap.get(row1.columnName))
;
}
System.out.println(x);