Five Stars

tsetglobalvar returns null for the value of output from tmap

The variable from tSetglobalvar is returning null when tried to print from tjava or used in expression of tmap.

Design and requirement:

Check for maximum ID using SQL in a table and add 1 to the max value in tmap. Get tmap output column in tsetglobalvar as variable and use this in next sub job's tmap expression. Currently this is printing null

toracleinput -> tmap -> tsetglobalvar -> On sub job OK ->tjava(System.out.println(globalMap.get("Campaign_ID"))Smiley Wink

 

1 ACCEPTED SOLUTION

Accepted Solutions
Twelve Stars TRF
Twelve Stars

Re: tsetglobalvar returns null for the value of output from tmap

Sorry, I didn't look carefully at the job design.

You have to replace tSetGlobalVar by tFlowToIterate to generate the global variable from the flow.

Capture.PNG

 

Then, you will have the global like this:

(Integer)globalMap.get("CAMPAIGNID")

 


TRF
6 REPLIES
Twelve Stars TRF
Twelve Stars

Re: tsetglobalvar returns null for the value of output from tmap

Hi,

Try this:

System.out.println(globalMap.get("Out.Campaign_ID"))

 


TRF
Five Stars

Re: tsetglobalvar returns null for the value of output from tmap

Thank you TRF. I still get the result as null

Six Stars

Re: tsetglobalvar returns null for the value of output from tmap

The "Value" column of the tSetGlobalVar should not be pulling from a global var itself.  If all you want to do is store the output of the tMap, use

Out.CAMPAIGNID

instead of 

((Integer)globalMap.get("Out.CAMPAIGNID"))

as the value. Since you never established a value earlier for the key "Out.CAMPAIGNID" then, this will return null

Five Stars

Re: tsetglobalvar returns null for the value of output from tmap

Thanks evansdar. I just did that and it threw an error. I changed value in tsetglobalvar to Out.CampaignID

 

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

Out cannot be resolved to a variable

Twelve Stars TRF
Twelve Stars

Re: tsetglobalvar returns null for the value of output from tmap

Sorry, I didn't look carefully at the job design.

You have to replace tSetGlobalVar by tFlowToIterate to generate the global variable from the flow.

Capture.PNG

 

Then, you will have the global like this:

(Integer)globalMap.get("CAMPAIGNID")

 


TRF
Five Stars

Re: tsetglobalvar returns null for the value of output from tmap

This works wonders. Thank you TRF. I have been struggling with this small part that is pending in my job. Can't thank you enough. have a good one.