Let's say I have 2 input files not containing a header or trailer record and I want to sort them into a single output file. Is there a way to add a trailer record to the output file for the end of each input file?
Example:
Input 1
-------
file 1 rec 1
file 1 rec 2
file 1 rec 3
Input 2
-------
file 2 rec 1
file 2 rec 2
file 3 rec 3
Output File
-----------
file 1 rec 1
file 1 rec 2
file 1 rec 3
End of file 1
file 2 rec 1
file 2 rec 2
file 3 rec 3
End of file 2
This code will only add single trailer at the end of the output file.
SORT FIELDS=COPY
OUTFIL REMOVECC,
TRAILER1=(1:'END OF FILE')
Thanks All!
//LRECL001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
//SORTIN DD *
End of file 1
//SORTOUT DD DISP=(,PASS,DELETE),
// LRECL=[lrecl for file 1],
// [other DD parameters as needed]
//*
//LRECL002 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
//SORTIN DD *
End of file 2
//SORTOUT DD DISP=(,PASS,DELETE),
// LRECL=[lrecl for file 2],
// [other DD parameters as needed]
//*
//CONCATN8 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
//SORTIN DD DISP=SHR,DSN=FILE1
// DD DISP=(OLD,DELETE),DSN=*.LRECL001.SORTOUT
// DD DISP=SHR,DSN=FILE2
// DD DISP=(OLD,DELETE),DSN=*.LRECL002.SORTOUT
//SORTOUT DD DISP=(,CATLG,DELETE),
// DSN=FILES.ONE.AND.TWO,
// [and so forth]