File3 : Header1,Detail1,Detail2,Trailer3
(Trailer3 : sum of the hash total fields of trailer 1+trailer 2)
Options we tried had 4 sort steps
Sort step 1 : Split header, trailer and details into 3 files.
Sort step 2 : To calculate the sum of hash totals in the trailer file splitted above
Sort step3 : Eliminate duplicate header record (Header2)
Sort step 4 : Merge detail file from step 1 + Trailer file from step2 + Header file from step3.
Can any one suggest a much easier solution to the above sort.
Please show an example of the records in each input file (relevant fields only) and what you expect for output. Give the RECFM and LRECL of each input file. Give the starting position, length and format of each relevant field.
Is there something in the header that identifies it (what)?
Is there something in the trailer that identifies it (what)?
The layout information is helpful, but I was also looking for an example of the records in each file and the expected output. It's not clear if you want the records of the second file appended after the records of the first file, or if you want the two files merged by a key or sorted by a key or what. I was hoping the example would make that clear.
Also, is the hashtotal for field1 the total of the amounts in positions 21-29 of the data records from both files or something else? Again, I was hoping the example would make that clear.
Hashtotal field1 in each of the file is the count of distinct records with respect to position 3 to 4 in the Detail record.
Hashtotal field2 in each of the file is the total count of detail records in the file.
In the output file there should be only one header and one trailer and all the detail records from both the input files as shown in the above eg:.Also the hash total in the trailer record of the output file would be the sum of the corresponding hash totals in the trailers in the input file.
Also the hash total in the trailer record of the output file would
be the sum of the corresponding hash totals in the trailers in the
I don't think so. For hash total 1, your example shows 2 for file1 and 2 for file2 so the sum would be 4, but you show 2 in the output. I think what you really want for hash total 1 is the count of distinct records for the merged D records - that would be 2 (just 00 and 01 in 3-4). Is that correct?
Can the Trailer be rebuilt as:
where TT00000000AAAAAAAAAA can be hardcoded and the two hash totals filled in from the appropriate counts?
Or must information from the input Trailer be kept in the output trailer (e.g. AAAAAAAAAA can change)?
That was a mistake I used the same file as File 1 and File2.In file 1 and File2 details records will never be the same.Especially the value from posititon 3 -4 between the 2 files will never be the same.So we can consider the 'D00' and 'D01' in file 2 as D'03' and 'D04' so the hashtotal-1 in the trailer filed is 4 and Hashtotal-2 in the trailer field will remian as '8'.
TT00000000AAAAAAAAAA cannot be hard coded as we have to retain the
value coming in the File1 in the output file trailer.