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

Capture the output of tJava in a file or another Talend Component?

Hello. I use a tJava component to call a third party API - the method being SHOWRUNNINGTASKS in their API library.
The tJava writes the following XML to the output console when the task is run. But how do I capture this output and save it in a file or use it for processing further such as extracting the TaskID element's value?
I'm new to Talend, and I couldn't find anything along this scenario in the forums.
Thank you.

<Response>
<CmdName>SHOWRUNNINGTASKS</CmdName>
<ReqID>4</ReqID>
<RepCode>0</RepCode>
<RepText></RepText>
<Time>2010-09-15 12:57:44</Time>
<Output>
<Tasks>
<SchedulerStatus>On</SchedulerStatus>
<Task>
<TaskID>847934091</TaskID>
<TaskName>SomeTask</TaskName>
<NominalStart>2010-09-15 12:46:00.00</NominalStart>
<TimeStarted>2010-09-15 12:50:17</TimeStarted>
<StartedBy>Scheduler</StartedBy>
<Status>Finding matching files on \\ShareX\ftp</Status>
<CurFileBytes>0</CurFileBytes>
<TotFileBytes>0</TotFileBytes>
<LastErrorType>0</LastErrorType>
<LastErrorText></LastErrorText>
</Task>
</Tasks>
</Output>
</Response>

If a similar question is asked before, please point me to it. Thank you again.
Labels (4)
2 Replies
Anonymous
Not applicable
Author

Can anyone help me with this please?
Anonymous
Not applicable
Author

Hello
Export the job script, create a new job and use tSystem component to call this job script. On tSystem, select "to global variable' on the standard output list. On a tJava component, get value of global variable and parse/split it to the expected result as you showed in the post, store the expected result to a global variable. In the next process, get the value of global variable on tFixedFlowInput and extract the TaskID element's value on tExtractXMLField, For example:
tSystem_1
|
onSubJobOK
|
tJava
|
onsubjobok
|
tFixedFlowInput--main--tExtractXMLField--tLogRow
on tJava:
String result=((String)globalMap.get("tSystem_1_OUTPUT");

Best regards
Shong