Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
How can we count the number of records in a dataset?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL
Author Message
gauravjha

New User


Joined: 16 Apr 2005
Posts: 1

PostPosted: Mon Apr 18, 2005 2:15 pm    Post subject: How can we count the number of records in a dataset?
Reply with quote

What are the possible ways to know the number of records in a data set( PS or VSAM)?
Back to top
View user's profile Send private message
References
andycool

Active User


Joined: 12 Apr 2005
Posts: 65

PostPosted: Mon Apr 18, 2005 8:05 pm    Post subject:
Reply with quote

Write a pgm which will do the following things:

1. Read the input file.
2. Set a counter to 0.
3. On every "Read" statement increment the counter UNTIL End Of File.
4. Display the counter in SYSOUT.

JCL step for this:

//stepname exec pgm=program
//input dd dsn=input_dataset
//sysout dd sysout=*
//
Back to top
View user's profile Send private message
somasundaran_k

Active User


Joined: 03 Jun 2003
Posts: 141

PostPosted: Mon Apr 18, 2005 8:14 pm    Post subject:
Reply with quote

If you want to use any utilities try Fileaid or Sort to find the record count.

hth
-Som
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 3265
Location: Charlotte,NC USA

PostPosted: Mon Apr 18, 2005 8:47 pm    Post subject: Re: How can we count the number of records in a dataset?
Reply with quote

The easiest way is to use DFSORT:
Code:

//*                                                 
//COUNT EXEC PGM=ICETOOL                         
//TOOLMSG  DD   SYSOUT=*                           
//DFSMSG   DD   SYSOUT=*                           
//IN       DD   DSN=MY.DATASET,DISP=SHR
//TOOLIN   DD   DATA                               
  COUNT FROM(IN)                                   
/*                                                 
//*

Or, to place the record count into an output dataset:
Code:
                                           
//COUNT EXEC PGM=SORT                             
//SORTIN   DD   DSN=MY.DATASET,DISP=SHR           
//SYSOUT   DD   SYSOUT=*                             
//SORTOUT  DD  DSN=MY.OUTPUT.DSN,DISP=(,CATLG,DELETE),...                             
//SYSIN    DD   DATA                                 
  OPTION COPY                                         
  OUTFIL REMOVECC,NODETAIL,                           
    SECTIONS=(1,2,                                   
      TRAILER3=(1:COUNT=(M10,LENGTH=10)))             
/*         
Back to top
View user's profile Send private message
andycool

Active User


Joined: 12 Apr 2005
Posts: 65

PostPosted: Mon Apr 18, 2005 9:00 pm    Post subject:
Reply with quote

Right !
This is where experience stands out.
Appreciations SuperK
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 4579
Location: San Jose, CA

PostPosted: Mon Apr 18, 2005 9:25 pm    Post subject:
Reply with quote

Superk,

Your second DFSORT job should be:

Code:

//COUNT EXEC PGM=SORT
//SORTIN   DD   DSN=MY.DATASET,DISP=SHR
//SYSOUT   DD   SYSOUT=*
//SORTOUT  DD  DSN=MY.OUTPUT.DSN,DISP=(,CATLG,DELETE),...
//SYSIN    DD   DATA
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    TRAILER1=(COUNT=(M10,LENGTH=10))
/*


TRAILER1 will give a single record with the count. It doesn't make sense to use SECTIONS/TRAILER3 in this case, since that would give a count for each value in positions 1-2.
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 154

PostPosted: Tue Apr 19, 2005 12:43 am    Post subject:
Reply with quote

Frank Yaeger wrote:
Superk,

Your second DFSORT job should be:

Code:

//COUNT EXEC PGM=SORT
//SORTIN   DD   DSN=MY.DATASET,DISP=SHR
//SYSOUT   DD   SYSOUT=*
//SORTOUT  DD  DSN=MY.OUTPUT.DSN,DISP=(,CATLG,DELETE),...
//SYSIN    DD   DATA
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    TRAILER1=(COUNT=(M10,LENGTH=10))
/*


TRAILER1 will give a single record with the count. It doesn't make sense to use SECTIONS/TRAILER3 in this case, since that would give a count for each value in positions 1-2.



1) I have a file with a HEADER REC and a TRAILER REC and the Trailer will contain the Total count of the records in a particular position excluding the Header and Trailer
2) Now I take the File and strip some records for testing purposes, But the Trailer count wont tally
3) I want to tally the total number of records and the position of the Total count wont be same for all the files.
4) Is there anyway I can do the tallying of the recs using SYNCSORT.
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 3265
Location: Charlotte,NC USA

PostPosted: Tue Apr 19, 2005 12:57 am    Post subject: Re: How can we count the number of records in a dataset?
Reply with quote

Thanks. I think I posted the example code from a job that actually did give a count for each value.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 4579
Location: San Jose, CA

PostPosted: Tue Apr 19, 2005 1:25 am    Post subject:
Reply with quote

die7nadal,

FYI, I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 154

PostPosted: Tue Apr 19, 2005 1:40 am    Post subject:
Reply with quote

Frank Yaeger wrote:
die7nadal,

FYI, I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.


Okie frank, make it in DFSORT.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 4579
Location: San Jose, CA

PostPosted: Tue Apr 19, 2005 3:19 am    Post subject:
Reply with quote

Quote:
Okie frank, make it in DFSORT.


Let me rephrase that: I'm happy to answer questions for customers who are using DFSORT, but I don't answer questions for customers who aren't using DFSORT.

You said you were using Syncsort. Do you have DFSORT as well?
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 154

PostPosted: Tue Apr 19, 2005 9:34 am    Post subject: Re: How can we count the number of records in a dataset?
Reply with quote

yeah I have DFSORT in my installation now.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 4579
Location: San Jose, CA

PostPosted: Tue Apr 19, 2005 8:16 pm    Post subject:
Reply with quote

Ok, then please show an example of your input records and what you want the output records to look like. Also, what is the RECFM and LRECL of the input file.
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 154

PostPosted: Tue Apr 19, 2005 9:13 pm    Post subject: Re: How can we count the number of records in a dataset?
Reply with quote

The recs look like below
Code:
********************************* Top of Data ***********
CNTL  0150400002        000001                           
00204505000039620E001S2911116    631               620207
00204481335000020103614633034    995               881020
0010 481335000020100014633034    995               881020
00204481335000020103623333033    996               881020
0010 481335000020100023333033    996               881020
00204481335000010102223479999    968               880810
00201481335000010199923479999    968               880810
00201481335000010199923479999    968               880810
00204481335000010102229275600    969               880810
00202481335000010199929275600    969               880810
00202481335000010199929275600    969               880810
TRLR  0150400002  000000000013                           
******************************** Bottom of Data *********


There will be only one Header CNTL rec and one Trailer TRLR Rec. The Trailer will contain the total count of the records exclusive of CNTL, TRLR rec in a particular position. Now if I strip certain recs I need to automatically tally the total no. of recs at the TRLR rec. Should I necessarily give the position of the Total recs count in TRLR rec, becos I have a number of similar files where the position of Total recs count may not be same in the above file it starts from 19 is 12 cols long. If u need some more info please lemme know.
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 154

PostPosted: Tue Apr 19, 2005 9:19 pm    Post subject: Re: How can we count the number of records in a dataset?
Reply with quote

The RECFM is VB and the LRECL is 57.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL All times are GMT + 6 HoursGoto page 1, 2  Next
Page 1 of 2