Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everybody.
I've got an entry flow, and I have to deplicate some rows.
More precisely, in my input there is a field that specified how many time I have to duplicate the row.
For exemple, my input is:
product;number
book;2
coat;0
plate;3
My output needs to be:
product
book
book
plate
plate
plate
Does anyone have any thought ?
Forget this post, other screen captures have been lost
1) Join your data as the Main flow to a tMap.
2) As the Lookup, join a tJavaFlex with a single int column ("number")
3) Inside the tMap, join the "number" column on your Main to the "number" column on your Lookup. Set the "Lookup Model" to "Reload at Each Row", the "Match Model" to "All Matches" and the "Join Model" to "Inner Join".
4) You will see a "globalMap Key" section appear. Click the green plus symbol and call the "globalMap Key" "count" and link your "number" column from your Main row to it.
5) Create an output table and link your "Product" record.
6) In your tJavaFlex (assuming you have already created your "number" column, add the following code to the Start Code.....
// start part of your Java code int count = ((Integer)globalMap.get("count")); for(int i = 0; i<count; i++){
7) Add this to your Main Code....
row18.number = count;
Note: row18 is just in my example. Yours will have to match the row name coming out of the tJavaFlex
😎 Add this to your End Code....
}
Your job will look like this (I'm using a tFixedFlowInput to simplify my example)....
Your tMap will something like this......
When you run this, the row will be multiplied by the number supplied on it. If the number is 0, then no row will be output.
Thanks everybody for your help.
I've impleted the fdenis's solution :
tFlowToIterate -> tLoop -> tIterateToFlow
with in the tLoop , input.numberinto the "To" field
It's work well and the entries with (input.number == 0) are abandoned.
Great thanks to rhall_2_0 for your exhaustive explanation.
Your solution seems more smart and with less components; I will try it later.