Page 1 of 1

Count number of records in a file - JCL SORT.

Posted: Wed Oct 15, 2014 1:40 pm
by Swapnil K
Hi,

I'm creating an ad-hoc report, for that purpose I have to count the no. of records and put the count in the output flat file. I need the data in the output file as "Count of records:" as one field and the "count" as second field. Please help me out.

Re: Count number of records in a file - JCL SORT.

Posted: Tue Oct 21, 2014 12:10 pm
by Anuj Dhawan
Hi,

Assuming a count of 99,999,999 will suffice, please try this:

Code: Select all

//STEP1 EXEC PGM=SORT 
//SYSOUT DD SYSOUT=* 
//SORTIN DD DSN=...  input file 
//SORTOUT DD DSN=... output file 
//SYSIN DD * 
  SORT FIELDS=COPY 
  OUTFIL REMOVECC,NODETAIL, 
   TRAILER1=('Count of records: ',COUNT=(M11,LENGTH=8)) 
/*