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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
su66
Contributor
Contributor

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"))0683p000009MA9p.png

 

Labels (3)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

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.

0683p000009Ls3m.png

 

Then, you will have the global like this:

(Integer)globalMap.get("CAMPAIGNID")

 

View solution in original post

7 Replies
TRF
Champion II
Champion II

Hi,

Try this:

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

 

su66
Contributor
Contributor
Author

Thank you TRF. I still get the result as null

Anonymous
Not applicable

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

su66
Contributor
Contributor
Author

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

TRF
Champion II
Champion II

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.

0683p000009Ls3m.png

 

Then, you will have the global like this:

(Integer)globalMap.get("CAMPAIGNID")

 

su66
Contributor
Contributor
Author

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.

Anonymous
Not applicable

Similar fault (and solution) here.  In fact three different reasons why a variable print might give a null back.  

 

To be fair Java is not my first coding language and I just copy-paste-hacked at the string part of the code to put a label on it instead of paying attention to what it actually said.   ...which is now obvious after reading the explanation above.  

 

1&2

 

WRONG (this gets a null and is the wrong type for the variable - 2 errors):

System.out.println(((String)globalMap.get("DEL: " + "tJDBCOutput_2_NB_LINE_DELETED")));

 

RIGHT: 

System.out.println(("ERR: " + (String)globalMap.get("tJDBCOutput_2_ERROR_MESSAGE")));
System.out.println(("LINE: " + (Integer)globalMap.get("tJDBCOutput_2_NB_LINE")));
System.out.println(("UPD: " + (Integer)globalMap.get("tJDBCOutput_2_NB_LINE_UPDATED")));
System.out.println(("INS: " + (Integer)globalMap.get("tJDBCOutput_2_NB_LINE_INSERTED")));
System.out.println(("DEL: " + (Integer)globalMap.get("tJDBCOutput_2_NB_LINE_DELETED")));
System.out.println(("REJ: " + (Integer)globalMap.get("tJDBCOutput_2_NB_LINE_REJECTED")));

 

Hope that helps someone who also wasn't looking properly.   

 

3

 

And one more...   0683p000009MACn.png

 

If you get a null in an output check the number near "tJDBCOutput_2_NB_LINE_REJECTED".   If you remove and re-add the same component during refactoring your flows the number of the component may alter so e.g. what was the java output object  tJDBCOutput_1 may become tJDBCOutput_2.     The log print is then left referencing the old entry unless you update it.