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
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.
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
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.
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