I have an input as a list of detail records. At the output side, i need to send the list of detail records along with a trailer record having the summation of the detail record for some fields.
May i know what is the best possible way to handle such a scenario.
Create a Structure for out put record, loop through your input detailed record list and use recordList size built in function to get sum of detailed record and map to output record structure. Create a flat file schema for the output record and use convert to string built-in service to generate flat file structure
Now, my output requires, the following,
001 024 456 010
001 324 434 025
001 724 456 015
050
002 024 456 010
002 324 434 010
020
The Header record is not needed in the output. The trailer record in the output is the summation of the 4th column in the detail record. In the output we need the Detail Records and after each set of detail records we need a trailer record with the total. 1st column is the serail no.
Now, to get the trailer record after each set of detail record, which is the best possible way.
I am defining the fields in the flat file schema. I donot have any seperate header record. I segregate with the record length, as the header record length is small than the detail. The length for header and detail records are fixed.