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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Multischema Input-XML output

I have a multischema input file. Each row is differentiated by a 2 byte identifier. I have created metadata for each schema. I am having difficulties proceeding further. How do I do validations like trailer is present or the counts in trailer are equal to the number of rows. How should I map and insert it in the database and produce XML's. Is there a sample project for the same? I am a newbie in the world or Talend
Labels (3)
7 Replies
Anonymous
Not applicable
Author

You can split the file into individual flows using tFileInputMSPositional.
Probably easier to then drop them into separate files e.g. header, trailer, type1, type2 etc.
Subjob 1 - test for missing trailer
To test if trailer exists you can then use tFileProperties>tFilterRow>tdie - in the filter test for a size of 0. If the size is zero then the file is empty and the tdie will kill the process.
Subjob 2 - Check counts
Use tFileRowCount on the detail file(s). (note the context Variable of "Count" for each one).
use tRowGenerator to create a single record with a dummy key (e.g. set to 1) and a count field (which is the sum of the file counts)
Input the trailer and create a similar record with same dummy key and trailer count.
Join using tMap and create a record with just the two separate counts
Use tFilterRow to check if the two fields match. If they don't then use tdie to kill the job.
Subjob 3 - Create XML
Use tFileOutputXML to create your output files.
Anonymous
Not applicable
Author

Thanks Rick.
Can you tell me how do you use the tFilterrow component to test file size?
Anonymous
Not applicable
Author

If you look at the schema for tFileProperties, you will see a field called "size". This is the size of the file.
So in tFilterRow add a new condition (green "+" sign)>Select InputColumn=size, Operator="equals" and set the Value column to 0 (zero).
Now go back to the canvas and connect the "Filter" output of tFilterRow to tDie. Change the error message in tDie to something sensible and the subjob/job will fail when the file is empty.
Rick
Anonymous
Not applicable
Author

I have another validation to be performed.
I have two variables (A & B) in Table00
I have to check values in these variables.
Either A or B can have values. Whichever has values it should be inserted in a new variable C.
If both the variables A or B have values. it should give an error.
Thanks.
Anonymous
Not applicable
Author

Hi gnaik,
What happens if both are blank? This could affect how you do this.
Regards
Rick
Anonymous
Not applicable
Author

Hi gnaik,
What happens if both are blank? This could affect how you do this.
Regards
Rick

Hi Rick,
If both are blank the variable C is also blank.
Thanks,
G
Anonymous
Not applicable
Author

Hi gnaik,
If you are doing this assignment in tmap I would recommend writing a code routine in Java, that way you can get the code to fail elegantly. If you haven't written one before then take a look at the string methods, they are a good place to start.
Regards,
Rick