Created on May 11, 2021, 12:34 p.m. - by Henry, Iris
I want to count the number of records in a file using the JCL sort utility and have to copy them to a specific position in an output file.
Please help me.
Try with OUTFIL REMOVECC command
I tried but not it is not working. if possible Please share example code
Try this code,
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('NUMBER OF RECORDS ARE:
',COUNT=(M11,LENGTH=8))
/*
I don't see any record in the output file.
Actually, my requirement is to count the number of records in a file. And then want to copy that count in a trailer record in the output file.
Remove NODETAIL from the SYSIN command to include the detailed report.
And, add specific position(see below code) on the trailer record based on your record layout,
TRAILER1=(30:'NUMBER OF RECORDS ARE:',COUNT=(M11,LENGTH=8))
it is not clear. Please show me some example code to understand
see this example,
CODE:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
DETAIL RECORD 5
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,
TRAILER1=('NUMBER OF RECORDS ARE:
',COUNT=(M11,LENGTH=8))
/*
OUTPUT:
DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
DETAIL RECORD 5
NUMBER OF RECORDS ARE:00000005