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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Compare row value with a global variable in tMap

Hi

I am fairly new to Talend with experience in other ETL tools.

 

I need to compare a global variable with an input field to make a decision

 

My use case is as follows

- We receive a multi-schema positional flat file with a header record and a trailer record.

- We need to count the total rows in the input file and compare with the value in the trailer record.

 

1) I use tfileInputMSPosition and split to different schema

2) Of the trailer output we tSchemaComplianceCheck for validation

3) using tMap to compare the record in trailer output with the global variable coming from tfileinputmsposititonal in the expression window as follows - row5.rec_count - ((Integer)globalMap.get("tFileInputMSPositional_1_NB_LINE")). The idea is to check if the operation results in zero or not.

 

Thanks for your help

 

 

 

 

Labels (1)
1 Reply
Anonymous
Not applicable
Author

You have a couple of things to consider here. How many of the rows in the file are you actually wanting to count? I assume that you do not want the header or footer counted in your total. The ((Integer)globalMap.get("tFileInputMSPositional_1_NB_LINE")) variable will count all rows output from the component. You also need to think about when the above value will be available and when you will have the total count of your relevant rows. You will definitely have the ((Integer)globalMap.get("tFileInputMSPositional_1_NB_LINE")) value available after the subjob which includes this component is finished. You will also have the footer row processed by the end of this subjob. The way I would do this is to calculate how many rows from ((Integer)globalMap.get("tFileInputMSPositional_1_NB_LINE")) you may need to throw away (assuming a header and footer are included, that will be 2). Then save the footer count value in another globalMap value. Then in the subjob starts after this subjob ( joined by an OnSubJobOk link), simply compare the values in a tMap there.