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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] How to get subjob received parameter?

Hello,
I'm using parameters to transmit context value from main job parent to subjob child. That works fine.
I wander how I can get back received parameters from subjob child operation such as the number of row inserted.
Main job
parameters values
ExportFileName ...
NbInserEnreg context.NbInserEnreg
Subjob child
context.NbInserEnreg = ((Integer)globalMap.get("tJDBCOutput_2_NB_LINE_INSERTED"));
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,
One solution is to use a tContextDump and a tBufferOutput at the end of the child job.
Then in the father job you can retrieve the parameters by linking a tContextLoad to the tRunJob.
Have a look at this topic for more info: http://www.talendforge.org/forum/viewtopic.php?pid=26940
Hope this helps,
Karine

View solution in original post

8 Replies
Anonymous
Not applicable
Author

Hi,
One solution is to use a tContextDump and a tBufferOutput at the end of the child job.
Then in the father job you can retrieve the parameters by linking a tContextLoad to the tRunJob.
Have a look at this topic for more info: http://www.talendforge.org/forum/viewtopic.php?pid=26940
Hope this helps,
Karine
Anonymous
Not applicable
Author

Hi,
I had a look but there are no sample of the way to use these components even in the TOS documentation. "No scenario is available for this component yet."
I know I could also use an intermediate file to share these data between parent and child but I'd rather work in memory.
Could you give me more information about
tContextLoad, tContextDump, tBufferOutput for this purpose of retreiving parameters values from a child job?
how to retreive value from key for some context parameter?
Anonymous
Not applicable
Author

Or you could use this custom component : http://www.talendforge.org/exchange/tos/extension_view.php?eid=155
Or the child job tContextDump component writes to a file then the parent job from this file tContextLoad.
Anonymous
Not applicable
Author

Please see attached screenshots for an example of how to use tContextLoad, tContextDump and tBufferOutput components.
In the scenario, the child job transfers all the context parameters which are also in father job context.
The tBufferOutput in child job and the tRunJob in father job should have the same schema (key,value). If you're using TOS 3.1.x, in the tRunJob component you can directly retrieve the schema from the tbufferOutput using the "copy child job" button.
Hope it's clear enough,
Karine
Anonymous
Not applicable
Author

Hi,
thanks for your help.
I first set the context.NbInserEnreg to 0 in the parent job
I use tRunJob with the "load" link to tContextLoad: I see many rows corresponding to context key values, but the context value NbInserEnreg set to XX in the child job is not retreived in the parent job after tRunJob...
I add tContextDump -->tBufferOut as the last step of my child job (schema key/value)
However context is not exactly the same in both job as I use many contexts parameter (database, file, ...).
context.NbInserEnreg is defined in both jobs.
Anonymous
Not applicable
Author

Hi,
I think it's because the tContextDump doesn't take the new value of your parameter.
Context parameters are stored in 2 places context.Name and context.setProperty("Name",context.Name as a string).
So if you are using custom code to change the value of a parameter, you have to use both. Or you can use a tContextLoad instead of custom code...
Try to add this line in your child job:
context.setProperty("NbInserEnreg",String.valueOf(context.NbInserEnreg));
just after: context.NbInserEnreg = ((Integer)globalMap.get("tJDBCOutput_2_NB_LINE_INSERTED"));
It should do the trick.
Regards,
Karine
Anonymous
Not applicable
Author

I just found another solution, which is faster but it works if you have only one parameter to transmit to the father job.
Instead of adding the 2nd line, you can replace the tContextDump with a tFixedFlowInput to generate one row with 2 fields: key (string) and value (same datatype as the context parameter).
Then set "NbInserEnreg" for the key and context.NbInserEnreg for the value.
Regards,
Karine
Anonymous
Not applicable
Author

Hi,
thanks a lot for your help. ("Context parameters are stored in 2 places ")
Both solutions work fine!
Kind regards,
JNB