Page 1 of 2

Count the number of records in a file using SORT

PostPosted: Fri Jul 24, 2009 11:27 am
by RajendraPrabhuS
Hi, I just want to count the number of records in a file using JCL. Is there any utility to count the number of records? Can anyone help me on this please..

Re: How do we count the number of records in a file using JCL?

PostPosted: Fri Jul 24, 2009 12:00 pm
by expat
Let us clarify exactly what JCL is.

it is Job Control Language.

By itself it does nothing. It is used to invoke the chosen program and to define which datasets are to be used by the DD names associated with the chosen program.

JCL does not have magical powers that solve all problems, JCL is merely the vehicule for telling the processor which program you want it to execute.

So which program do you wish to execute to count the records ?

Re: How do we count the number of records in a file using JCL?

PostPosted: Fri Jul 24, 2009 1:53 pm
by RajendraPrabhuS
Thanks Swd....

Re: How do we count the number of records in a file using JCL?

PostPosted: Fri Jul 24, 2009 7:50 pm
by Alissa Margulies
If you have SyncSort for z/OS, here is a sample job that will produce the record count:
//SORT1 EXEC PGM=SORT 
//SYSOUT  DD SYSOUT=*               
//SORTIN  DD DSN=Input.File,DISP=SHR 
//SORTOUT DD DSN=Output.File,...
//SYSIN   DD *                       
   SORT FIELDS=COPY                   
   OUTFIL FILES=OUT,TRAILER1=(1:COUNT),REMOVECC,NODETAIL           
/*                                   

Re: How do we count the number of records in a file using JCL?

PostPosted: Fri Jul 24, 2009 8:06 pm
by RajendraPrabhuS
Hi Alissa Margulies, Thank for this... Can you please explain the following line.. I don't understand..

SORT FIELDS=COPY
OUTFIL FILES=OUT,TRAILER1=(1:COUNT),REMOVECC,NODETAIL

:?:

Re: How do we count the number of records in a file using JCL?

PostPosted: Fri Jul 24, 2009 8:22 pm
by Alissa Margulies
RajendraPrabhuS,

This job creates a report with a single trailer record containing the record count.

The COUNT subparameter of TRAILER1 provides the number of records for the entire report (all the records) starting at position 1.

REMOVECC omits the ANSI carriage control character from all of the report records.

NODETAIL generates a report with no data records, only header and trailer records, as specified.

Hope this helps. Let me know if you have any further questions.

P.S. All of this is fully documented in the SyncSort for z/OS Programmer's Guide. If you are a licensed customer but do not have access to the documentation, please contact SyncSort Mainframe Product Services and we would be happy to provide them to you.

Re: How do we count the number of records in a file using JCL?

PostPosted: Mon Jul 27, 2009 9:30 am
by RajendraPrabhuS
Thanks you soo much Alissa

Re: How do we count the number of records in a file using JCL?

PostPosted: Fri Aug 14, 2009 10:54 pm
by sricsc
I have a question, can I count the total records in more than one PS file in the same SYNCSORT step ?

Re: How do we count the number of records in a file using JCL?

PostPosted: Sat Aug 15, 2009 1:42 am
by ranga_subham
Yes. In that case you would be using PGM=SYNCTOOL instead of PGM=SYNCSORT.

Thanks.

Re: How do we count the number of records in a file using JCL?

PostPosted: Sat Aug 15, 2009 11:52 am
by sricsc
Hi Ranga,

Thanks for your response.
But I dont know the how to use the SYNCTOOL. Can you pls tell me the SYNCTOOL syntax & how to use in my job ?
And also how to check the SYNCTOOL is installed in my system ?