|
|
| Author |
Message |
gauravjha
New User
Joined: 16 Apr 2005 Posts: 1
|
|
|
|
| What are the possible ways to know the number of records in a data set( PS or VSAM)? |
|
| Back to top |
|
 |
References
|
|
 |
andycool
Active User
Joined: 12 Apr 2005 Posts: 65
|
|
|
|
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 |
|
 |
somasundaran_k
Active User
Joined: 03 Jun 2003 Posts: 141
|
|
|
|
If you want to use any utilities try Fileaid or Sort to find the record count.
hth
-Som |
|
| Back to top |
|
 |
superk
Moderator Team Head
Joined: 26 Apr 2004 Posts: 3265 Location: Charlotte,NC USA
|
|
|
|
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 |
|
 |
andycool
Active User
Joined: 12 Apr 2005 Posts: 65
|
|
|
|
Right !
This is where experience stands out.
Appreciations SuperK |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4579 Location: San Jose, CA
|
|
|
|
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 |
|
 |
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 154
|
|
|
|
| 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 |
|
 |
superk
Moderator Team Head
Joined: 26 Apr 2004 Posts: 3265 Location: Charlotte,NC USA
|
|
|
|
| Thanks. I think I posted the example code from a job that actually did give a count for each value. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4579 Location: San Jose, CA
|
|
|
|
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 |
|
 |
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 154
|
|
|
|
| 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 |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4579 Location: San Jose, CA
|
|
|
|
| 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 |
|
 |
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 154
|
|
|
|
| yeah I have DFSORT in my installation now. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4579 Location: San Jose, CA
|
|
|
|
| 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 |
|
 |
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 154
|
|
|
|
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 |
|
 |
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 154
|
|
|
|
| The RECFM is VB and the LRECL is 57. |
|
| Back to top |
|
 |
|
|