In my job, I need to write the header records from File 1 followed with the detail records of file 1 and then with Detail records of file 2 at the end need to add the trailer records from File 1 .
Please help how we can implement it using WHEN=GROUP or suggest any options to sort this out. Although we send the trailer records having the wrong counts since we haven't included the new detail records count that not a issue for the receipient team.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
If your trailer can be generated then it you can get away with a COPY operation like below
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=Input file 1 with header/detail/trailer records
// DD DISP=SHR,DSN=Input file 2 with just detail records
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OMIT COND=(1,2,CH,EQ,C'TT')
OUTFIL REMOVECC,
TRAILER1=(C'TT',COUNT-1=(M11,LENGTH=6))
//*
If you need the original trailer record as is then use the following control cards. I assumed that you need to update the detail record count in position 3 on the trailer record.
Joined: 16 Mar 2008 Posts: 90 Location: tamil nadu
Hi ,
Thanks a lot for your help
May be i will omit the trailer file and write it to another file and merge the header 1 detail detail 2 along with trailer 1 in another step
If your trailer can be generated then it you can get away with a COPY operation like below
Code:
If you need the original trailer record as is then use the following control cards. I assumed that you need to update the detail record count in position 3 on the trailer record.
But i am not able to understand the below code.
IS this for generating a new trailer ...
Code:
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Another option, using JOINKEYS to "merge" the data. On the first file, all records get extended (I've used F, 80 , records for the example) with X'00' except for the trailer which gets X'FF'. All records on the second file get X'FE', Then JOINKEYS is used , with only unmatched records, and the output is stitched together.
If you want the trailer, you can include Kolusu's OUTFIL code alongside.