Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to count number of records in a dataset using cobol pgm

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
kris22_24

New User


Joined: 28 Oct 2006
Posts: 18

PostPosted: Mon Apr 23, 2007 10:52 pm    Post subject: How to count number of records in a dataset using cobol pgm
Reply with quote

How to count number of records in a data set using cobol program?
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Apr 23, 2007 10:56 pm    Post subject:
Reply with quote

move zero to count
perform until eof
read file
at end set eof to true
not at end add 1 to count
end-read
end-perform
display count.
Back to top
View user's profile Send private message
kris22_24

New User


Joined: 28 Oct 2006
Posts: 18

PostPosted: Mon Apr 23, 2007 10:59 pm    Post subject: Re: How to count number of records in a dataset using cobol
Reply with quote

i want to check the data sets with these conditions...if "AN, BN,CN,DN,EN,FN,GN,UN,PN,SN,MN,NN" these are present i want to count how many records are present?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Apr 23, 2007 11:08 pm    Post subject:
Reply with quote

Hello,

Using the code suggested above, include an array of 2 fields - the 2-char alpha-code and a counter. Initialize the alpha-codes from your list or build them dynamically. Set the counters to zero.

As the program reads the records, add 1 to the appropriate counter in the array.
Back to top
View user's profile Send private message
kris22_24

New User


Joined: 28 Oct 2006
Posts: 18

PostPosted: Mon Apr 23, 2007 11:37 pm    Post subject: Re: How to count number of records in a dataset using cobol
Reply with quote

sorry, i dint understand what exactly should do.. can u please write in detail with codings...
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Apr 23, 2007 11:44 pm    Post subject:
Reply with quote

kris22_24 wrote:
sorry, i dint understand what exactly should do.. can u please write in detail with codings...
Since you are unfamiliar with COBOL, why don't you add an INCLUDE card to the sort solution you got a couple weeks back in How to count number of records in VSAM data set?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Apr 24, 2007 1:21 am    Post subject:
Reply with quote

Hello,

If you need a quick solution, the SORT/INCLUDE will get the result you want.

If you want to learn more about COBOL, you can put together the basic program Bill described and run it - this will count all of the records in the file. Once you have the code that reads/counts all of the records, you might try the following approaches to learn some other techniques.

To then count by alpha-code, you could try the array approach (as you will need to learn about array processing anyway if you are going to be a COBOL programmer). You could also sort the records by alpha-code and summarize record counts by alpha-code and this approach would not require an array.

I'd suggest that you try all 3 sets of code - they will be small and will not take a long time to work on. Once you have the first set of code working (the overall read/count) the other 2 will be clones and take less code as you will only be adding the additonal code to implement these 2 ways of getting the summaries. When you have all 3 running correctly, set them aside to use as examples later.

If you post what you have as you work on this, we can offer suggestions when there are questions. When you post program code or jcl, it is a good idea to post using the "Code" tab at the top of the reply panel - this makes the info much more readable.
Back to top
View user's profile Send private message
nandu404

New User


Joined: 20 Sep 2006
Posts: 4

PostPosted: Thu Apr 26, 2007 11:25 am    Post subject: Re: How to count number of records in a dataset using cobol
Reply with quote

Hi,

You could code an IF condition in your COBOL program with the required values and increment the counter inside that.
(if you don't want to use SORT card)
Back to top
View user's profile Send private message
socker_dad

Active User


Joined: 05 Dec 2006
Posts: 147
Location: Columbia, MO

PostPosted: Thu Apr 26, 2007 8:59 pm    Post subject: Re: How to count number of records in a dataset using cobol
Reply with quote

Or you could simply pick up a COBOL programming manual and actually READ it..... icon_idea.gif
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Apr 27, 2007 12:54 pm    Post subject:
Reply with quote

Dare I ask why on earth you would want to reinvent the wheel.

HOMEWORK perhaps ?

SORT, IEBGENER, just to name two quick ways to get the count and you only have to code a couple of lines of control statements.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 964
Location: Richmond, Virginia

PostPosted: Fri Apr 27, 2007 5:45 pm    Post subject:
Reply with quote

How does IEBGENER count? Where's the output show?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Apr 27, 2007 5:51 pm    Post subject:
Reply with quote

The output shows in SYSPRINT, but then here it executes ICEGENER.

Yeah, I know, it's not an ideal solution, but then the OP wasn't clear on the reason for wanting to do this.
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 205
Location: Bangalore

PostPosted: Mon Apr 30, 2007 12:53 pm    Post subject: Re: How to count number of records in a dataset using cobol
Reply with quote

Use the following job:

//Your job card i.e job statement
//*------------------------------------------------------------------*
//* COUNTS THE NO OF RECORDS IN THE FILE. *
//*------------------------------------------------------------------*
//TOOL EXEC PGM=ICETOOL,REGION=128M
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//INFILE DD DSN=MYDATASET,DISP=OLD
//TOOLIN DD *
COUNT FROM(INFILE)
/*

check for the outout count in the TOOLMSG
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Browse dataset cvnlynn CLIST & REXX 4 Tue Jul 18, 2017 3:52 am
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts CICS Transaction attach count of supp... lind sh CICS 1 Wed Jun 21, 2017 1:33 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us