I am working on a SORT card and have come to a point where I would need some advise to proceed further. Also I did some searching within the forum but cannot solution that fit in my requirement.
My requirement :
I have two flat files with LRECEL = 96 and FB. Both files having same layout and having one header/trailer record. I want to sort both the files but in the output i need one header and one trailer.
Header on both files are same so can be taken one and skip one.But in the output trailer I want to sum up count value(Position is 18 and of length 7) and amount value(Position is 25 and of length 13) from both the trailers.
Below is sample input file.
***************************** Top of Data ******************************
129998888885 96030800101810999
549998888885 455206140345159010181000000008031P4552999 0890989749100
549998888885 455206140345216810181000000014000P4552999 0890989749100
549998888885 455206140345293710181000000006000P4552999 0890989749100
549998888885 455206140345348910181000000029849P4552999 0890989749100
549998888885 455206140345764710181000000002500P4552999 0890989749100
549998888885 455206140345874410181000000005000P4552999 0890989749100
549998888885 455206140346237310181000000013471P4552999 0890989749100
549998888885 455206140346470010181000000010000P4552999 0890989749100
549998888885 455206140348372610181000000020000P4552999 0890989749100
549998888885 455206140348417910181000000002000P4552999 0890989749100
549998888885 455206140348469010181000000029156P4552999 0890989749100
549998888885 455206140349201610181000000006000P4552999 0890989749100
549998888885 455206140349810410181000000002000P4552999 0890989749100
549998888885 455206140349813810181000000000100P4552999 0890989749100
549998888885 455206140350572610181000000080681P4552999 0890989749100
929998888885 000001E000000022878Q
129998888885 96030800101810999
549998888885 455206140345159010181000000008031P4552999 0890989749100
549998888885 455206140345216810181000000014000P4552999 0890989749100
549998888885 455206140345293710181000000006000P4552999 0890989749100
549998888885 455206140345348910181000000029849P4552999 0890989749100
549998888885 455206140345764710181000000002500P4552999 0890989749100
549998888885 455206140345874410181000000005000P4552999 0890989749100
549998888885 455206140346237310181000000013471P4552999 0890989749100
549998888885 455206140346470010181000000010000P4552999 0890989749100
549998888885 455206140348372610181000000020000P4552999 0890989749100
549998888885 455206140348417910181000000002000P4552999 0890989749100
549998888885 455206140348469010181000000029156P4552999 0890989749100
549998888885 455206140349201610181000000006000P4552999 0890989749100
549998888885 455206140349810410181000000002000P4552999 0890989749100
549998888885 455206140349813810181000000000100P4552999 0890989749100
549998888885 455206140350572610181000000080681P4552999 0890989749100
929998888885 000001E000000022878Q
Trailer copybook structure is
01 W1242-TRAILER-RECORD REDEFINES W1242-RECORD.
05 FILLER PIC X(17).
05 W1242-TOTAL-COUNT PIC S9(7).
05 W1242-TOTAL-AMOUNT PIC S9(13).
05 FILLER PIC X(59).
05 FILLER PIC X(17).
05 W1242-TOTAL-COUNT PIC S9(7).
05 W1242-TOTAL-AMOUNT PIC S9(13).
05 FILLER PIC X(59).
Header starts from 1
Detail Record starts from 5
Trailer starts from 9
Actual trailer count is 15 and Amount is -228788 in above sample file.