View previous topic :: View next topic
|
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 |
|
|
andycool
New User
Joined: 12 Apr 2005 Posts: 64
|
|
|
|
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: 134
|
|
|
|
If you want to use any utilities try Fileaid or Sort to find the record count.
hth
-Som |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, 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
New User
Joined: 12 Apr 2005 Posts: 64
|
|
|
|
Right !
This is where experience stands out.
Appreciations SuperK |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 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: 156
|
|
|
|
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
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, 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 Developer
Joined: 15 Feb 2005 Posts: 7129 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: 156
|
|
|
|
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 Developer
Joined: 15 Feb 2005 Posts: 7129 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: 156
|
|
|
|
yeah I have DFSORT in my installation now. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 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: 156
|
|
|
|
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: 156
|
|
|
|
The RECFM is VB and the LRECL is 57. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Can you recreate the TRLR record, that is, rebuild it on the fly with the information you need in it, or do you have to merge the new count into the existing trailer record? It looks like the trailer record only has three fields: 'TRLR' is a constant so it can be rebuilt on the fly. The count-2 can be rebuilt on the fly. So the question is can the 0150400002 field be rebuilt on the fly - is it always going to be 0150400002, or something else that can be built (e.g. the run date), or does it have to be saved from the trailer record and put back into it?
Quote: |
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. |
Are you saying that the count may be in different places in the trailer record for different input files? If so, what is it you want to know about that? |
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
|
|
I cannot recreate the TRLR record, I just want to update the Record count in trailer Or it can be saved from the trailer rec and put back.
I wanted to know if I have to give the position of the count in the Control Card or if It can find by itself, bcos I have different File where the position of Recs count may vary Or in other words I wont know the position of the record Count. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT/ICETOOL job that will give you what you want. You will have to change the job for different count locations, but I've used DFSORT Symbols to make that easier. Just map different records with the appropriate symbols.
You'll also need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) to use DFSORT's new COUNT-n and IFTHEN functions. If you have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it.
Code: |
//S1 EXEC PGM=ICETOOL
//SYMNAMES DD *
*TRAILER RECORD SYMBOLS
* |RDW|'TRLR'|KEEP|count|
RDW,1,4 RDW
ID,*,4,CH 'TRLR' location
KEEP,*,14 Length of bytes between 'TRLR' and count
TRLID,'TRLR' 'TRLR' id
DELID,'TTTT' 'TTTT' id
/*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (VB)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file (VB)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
COPY FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
* Change 'TRLR' in the original trailer record to 'TTTT'.
INREC IFTHEN=(WHEN=(ID,EQ,C'TRLR'),OVERLAY=(5:DELID))
* Create a new trailer record with 'TRLR', the data from the
* original trailer record and a count of the data records
* (total input records - 2).
* T1 will have the header record, the data records, the
* 'TTTT' record and the new 'TRLR' record.
OUTFIL FNAMES=T1,REMOVECC,
TRAILER1=(TRLID,KEEP,COUNT-2=(M11,LENGTH=12))
/*
//CTL2CNTL DD *
* Remove the 'TTTT' record.
OMIT COND=(ID,EQ,DELID)
/*
|
|
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
|
|
Thanks Frank |
|
Back to top |
|
|
|