[resolved] tmap update current row with previosu row info

One Star

[resolved] tmap update current row with previosu row info

I have been unsuccessfully trying to use tmap as the last part of a process, which I will summarize as follows:
The process extracts information from a Cobol proprietary system, w/o table maps.
As a result the only information available is in the form of a print formatted report.
The Java process have different sub jobs that do: a) clean headings b) create a row counter c) separate info (positional rows) according to 4 criteria (agent info, customer info, invoice info, transactions info). d) create 4 tab delimited files e) reassemble the files as tab delimited using the row counter as guide.
All successful. I end with a file looking like this(summary):
Record Record_type Agent Customer Invoice Transactions
1 1 aaaa
2 2 xxxxxx
3 3 FV-001
4 99 00111
5 99 00228
6 1 bbbb
7 2 yyyyyy
8 3 FV-002
9 99 00879
fields Record and Record_type are integer. Agent, Customer, Invoice and Transactions are String. Table is sorted by Agent, Customer and Invoice.
I have been unable to create a way in tmap to update the table rows in a way that keeps the first agent name while the agent name is null or empty string in the input flow and updates to the new agent name as input row agent is not null or not empty string:
tFileInputdelimited ---> tmap --> tFileOutputDelimited
Record Record_type Agent Customer Invoice Transactions
1 1 aaaa
2 2 aaaa xxxxxx
3 3 aaaa FV-001
4 99 aaaa 00111
5 99 aaaa 00228
6 1 bbbb
7 2 bbbb yyyyyy
8 3 bbbb FV-002
9 99 bbbb 00879
I have already searched throughout the forum and checked several related threads w/o success. Any help would be really appreciated Smiley Happy.

Accepted Solutions
One Star

Re: [resolved] tmap update current row with previosu row info

I found out. It is in the output row area. I am posting a complete update with pictures in order to explain in detail what John instructed. Once again thanks to John. Smiley Happy Smiley Happy.
All in all it works flawlesly.

All Replies

Re: [resolved] tmap update current row with previosu row info

You can use a tJavaRow to save the previous value of the column, and then apply that in a tMap:
tFileInputdelimited ---> tJavaRow --> tmap --> tFileOutputDelimited
in the tJavaRow, save the value to the globalMap:
if(input_row.Agent != null && !"".equals(input_row.Agent) ) {
globalMap.put("Agent_prev_value",input_row.Agent);
}
Then in the tMap:
row2.Agent == null || "".equals(row2.Agent) ? (String)globalMap.get("Agent_prev_value") : row2.Agent
One Star

Re: [resolved] tmap update current row with previosu row info

John,
Thank you for your quick reply. In the tmap you would put the expression in the variables area or in the output row area?
One Star

Re: [resolved] tmap update current row with previosu row info

I found out. It is in the output row area. I am posting a complete update with pictures in order to explain in detail what John instructed. Once again thanks to John. Smiley Happy Smiley Happy.
All in all it works flawlesly.