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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[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 0683p000009MACn.png.
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

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. 0683p000009MACn.png 0683p000009MACn.png.
All in all it works flawlesly.

View solution in original post

3 Replies
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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?
Anonymous
Not applicable
Author

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. 0683p000009MACn.png 0683p000009MACn.png.
All in all it works flawlesly.