IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

VSAM record count


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rdasari123

New User


Joined: 28 Aug 2008
Posts: 8
Location: Wilson, NC

PostPosted: Thu Aug 28, 2008 8:19 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Aug 28, 2008 8:26 pm
Reply with quote

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
View user's profile Send private message
rdasari123

New User


Joined: 28 Aug 2008
Posts: 8
Location: Wilson, NC

PostPosted: Thu Aug 28, 2008 8:34 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Aug 28, 2008 8:57 pm
Reply with quote

This can be accomplished via an Assembler program, which issues a SHOWCB Macro, FIELDS=NLOGR.

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Aug 28, 2008 8:57 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 28, 2008 9:37 pm
Reply with quote

Are not statistics for vsam only 'truely' accurate after a reorg?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Aug 28, 2008 10:48 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Aug 29, 2008 11:45 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top