COUNT records in a flat file



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

COUNT records in a flat file

Postby kevin1 » Sat Feb 27, 2010 6:12 am

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.
kevin1
 
Posts: 9
Joined: Sat Jan 30, 2010 8:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: COUNT records in a flat file

 

Re: COUNT records in a flat file

Postby Robert Sample » Sat Feb 27, 2010 6:32 am

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.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: COUNT records in a flat file

Postby kevin1 » Sat Feb 27, 2010 5:01 pm

Thank you so much Robert! :)
kevin1
 
Posts: 9
Joined: Sat Jan 30, 2010 8:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: COUNT records in a flat file

Postby ITConsultant » Sat Mar 13, 2010 3:47 am

A simpler way would be to execute the sort utility using JCL which will give you the number of records in and out.
ITConsultant
 
Posts: 15
Joined: Wed Mar 10, 2010 4:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: COUNT records in a flat file

Postby dick scherrer » Sat Mar 13, 2010 10:11 am

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. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post