Page 1 of 1

COUNT records in a flat file

PostPosted: Sat Feb 27, 2010 6:12 am
by kevin1
Hi :) everybody,

I need to find total number of records in a file using COBOL programme. Can anyone give some idea regarding this. Also, suggest me how to do this using JCL as well.

Regards,
Kevin.

Re: COUNT records in a flat file

PostPosted: Sat Feb 27, 2010 6:32 am
by Robert Sample
It cannot be done "with JCL". JCL does nothing but execute programs. They may be application programs, or utilities, or sort, or whatever -- but JCL cannot do anything else.

The most accurate (but expensive) way to do this in COBOL is to open the file, read each record of the file and add 1 to a counter for each successful read. When you hit the end of the file, you've counted all the records in the file.

Re: COUNT records in a flat file

PostPosted: Sat Feb 27, 2010 5:01 pm
by kevin1
Thank you so much Robert! :)

Re: COUNT records in a flat file

PostPosted: Sat Mar 13, 2010 3:47 am
by ITConsultant
A simpler way would be to execute the sort utility using JCL which will give you the number of records in and out.

Re: COUNT records in a flat file

PostPosted: Sat Mar 13, 2010 10:11 am
by dick scherrer
Hello,

The original request was:
need to find total number of records in a file using COBOL programme.


A simpler way would be to execute the sort utility using JCL which will give you the number of records in and out.
As this was a COBOL question, posted in the COBOL part of the forum, providing a COBOL reply would be more appropriate. . .