Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In my talend program ,we use a java code block to store context variables(global variables) like
context.header='ABCDEF';
(using the program logic) and it has a corresponding value ascontext.data=100;
Header->Subheader->data (Each header may contain 10 or just 1 subheader) ,i want to sum the total data value for a specific header(totalling all subheader data integer values) 2nd iteration wouldcontext.header='ABCDEF';context.data=400;
So each iteration would generate new values like (
context.header='XYZEAF'
) andcontext.data=150;
or it would retain the same value as such for the context.headerEssentially i would want to sum up the total of data integer value if it has the same header from the previous iteration or if it is a new header ,i would want to create a separate total for it like:
OUTPUT: Total data count: ABCDEF=500(100+400)............... XYZEAF=150..................and so on
Is there a way to capture the output from the previous iteration after each file processing in talend and compare against the latest iteration and perform the summation?
I was thinking possibly creating an arraylist which can dynamically grow in size and storing the header values in that for each iteration/run and then cross-check with the previous iteration if it had same header ->Just total it up else create a new counter for the new header for the total data.Please suggest some easier way of doing it
HI @Haresh, take a look a tFlowToIterate component :
https://help.talend.com/r/vn0o8XYVXXNgJkRtWjet9A/gQW7IzhQK0pr5oLxZWT_NQ
with it you can iterate your flow and it stock the values of each rows in globlaMap.
so at each iteration you can manipulate the values of the field of the row with values of the previous row you stocked before in other globalMap.
Send me Love and Kudos