|
|
| Author |
Message |
rdasari123
New User
Joined: 28 Aug 2008 Posts: 4 Location: Wilson, NC
|
|
|
|
Hi,
In a COBOL program, How to retrieve number of records in VSAM file (count) with out reading the file? OR How to retrieve the amount of space allocated to a VSAM file?
If there is no such facility in COBOL program, is there any utility which we can use in JCL and write that information to a dataset? |
|
| Back to top |
|
 |
References
|
|
 |
Robert Sample
Senior Member
Joined: 06 Jun 2008 Posts: 892 Location: Atlanta, GA
|
|
|
|
| IDCAMS LISTCAT will give you this -- write the output to a file instead of SYSOUT and then process it in your COBOL program. As far as I'm aware there's no other way in COBOL to access this type of data (especially without reading the file). |
|
| Back to top |
|
 |
rdasari123
New User
Joined: 28 Aug 2008 Posts: 4 Location: Wilson, NC
|
|
|
|
I did that.
I used IDCAMS LISTCAT. I do not find any option for record count. Can you tell the options I have to use exactly? |
|
| Back to top |
|
 |
Bill O'Boyle
Senior Member
Joined: 14 Jan 2008 Posts: 333 Location: Orlando, FL, USA
|
|
|
|
This can be accomplished via an Assembler program, which issues a SHOWCB Macro, FIELDS=NLOGR or via the REXX LISTDSI function.
SHOWCB Example -
| Code: |
LA R10,PGMWORKA POINT TO ALIGNED-WORKAREA (REQUIRED)
SHOWCB AM=VSAM,ACB=(R11),AREA=(R10),LENGTH=PRMVSAML, X
FIELDS=(NLOGR)
ST R15,RETNCODE STORE IN FWORD
MVC PRMRECDS,0(R10) POPULATE NBR-OF-RECORDS FWORD
CNOP 0,4 ENSURE FWORD ALIGNMENT
PGMWORKA DS XL256 PGM-WORKAREA
|
Regards,
Bill |
|
| Back to top |
|
 |
Robert Sample
Senior Member
Joined: 06 Jun 2008 Posts: 892 Location: Atlanta, GA
|
|
|
|
LISTCAT ENT(???) ALL is the precise command to use.
Part of the output for a VSAM file will be the STATISTICS section:
| Code: |
STATISTICS
REC-TOTAL----------10095 SPLITS-CI-------------20
REC-DELETED------------0 SPLITS-CA--------------0
REC-INSERTED---------250 FREESPACE-%CI---------10
REC-UPDATED----------118 FREESPACE-%CA---------10
REC-RETRIEVED-----483143 FREESPC----------2727936
ALLOCATION
SPACE-TYPE------CYLINDER HI-A-RBA---------7372800
SPACE-PRI-------------10 HI-U-RBA---------5160960
SPACE-SEC--------------5 |
REC-TOTAL is the record count. HI-A-RBA is the high allocated RBA, which tells you how many bytes are allocated; HI-U-RBA tells you the highest used RBA (which is NOT how many bytes are used in the file since free space can be in the used CI areas). |
|
| Back to top |
|
 |
dbzTHEdinosauer
Senior Member
Joined: 20 Oct 2006 Posts: 1618 Location: germany
|
|
|
|
| Are not statistics for vsam only 'truely' accurate after a reorg? |
|
| Back to top |
|
 |
Robert Sample
Senior Member
Joined: 06 Jun 2008 Posts: 892 Location: Atlanta, GA
|
|
|
|
It depends -- APAR OA06499 has this to say
| Quote: |
VSAM does not update data set statistics if the data set is not
closed properly. Thus, signifcant changes that should have been
reflected in the statistics for the data set will not appear.
That has led to significant confusion by customers, as they know
changes were made but they are not reflected in the statistics.
The content of the statistics information will be incorrect
until the data set is rebuilt; there is no way to correct them.
|
which implies that if the data set is closed properly the statistics will be updated. If the VAM file is open to CICS or a batch program when you're looking at the statistics, they may not be accurate. |
|
| Back to top |
|
 |
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 3509 Location: Brussels once more ...
|
|
|
|
| That's why it is advisable to run an IDCAMS VERIFY before the listcat, which does an open and close of the file. |
|
| Back to top |
|
 |
|
|