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

Whats the best way to count number of records in VSAM file?


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gnaveenkumar.99

New User


Joined: 21 Sep 2011
Posts: 8
Location: India

PostPosted: Wed Jan 23, 2013 8:33 pm
Reply with quote

Whats the best way to count the number of records in a VSAM File?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jan 23, 2013 8:36 pm
Reply with quote

Whilst reading the data for another purpose.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Jan 23, 2013 9:13 pm
Reply with quote

Hello,

If you are not working with some other process, you could copy the file using your sort product and specify DD DUMMY for the output. The entire input file would be read.
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: Wed Jan 23, 2013 9:42 pm
Reply with quote

You can obtain the number of records on a VSAM file ahead of time, without having to read the file, using a small in-house Assembler Batch program, which issues a SHOWCB Macro, specifying parameter FIELDS, with keyword NLOGR (a binary fullword).

The target file needs to be closed.

I've only used this for fixed-length VSAM files only.

HTH....
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Wed Jan 23, 2013 9:45 pm
Reply with quote

Our shop has a REXX command in 3.4 to give a Listcat but the following JCL works well too...
Code:
//*-- PURPOSE: LISTCAT OF VSAM FILE                             
//*-- NOTES:   GET FILE RECORD COUNT FROM DD-SYSPRINT; REC-TOTAL
//*-------------------------------------------------------------
//*                                                             
//STEP005  EXEC PGM=IDCAMS                                     
//SYSPRINT DD SYSOUT=*                                         
//SYSOUD   DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*                                         
//SYSIN    DD *                                                 
   LISTCAT ENTRIES (XXXXXXXX.XXXXXXXX.CLUSTER)   ALL           
/*   
Back to top
View user's profile Send private message
Pete Wilson

Active Member


Joined: 31 Dec 2009
Posts: 592
Location: London

PostPosted: Thu Jan 24, 2013 9:26 pm
Reply with quote

If you have it SYCHSORT HISTOGRAM is an option and also gives a break down of different record lengths.

Otherwise a sequential copy of the file with repro or sort to a dummy output DD will give a record count.

You can't rely on the record count in LISTCAT unless the file has been closed normally otherwise these stats are not accurate. If the file is closed running an IDCAMS VERIFY before the LISTCAT will ensure the stats are correct.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jan 24, 2013 10:05 pm
Reply with quote

ICETOOL COUNT will count records without having to specify a dummy dataset.

However, TS seems to have wondered off...
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: Fri Jan 25, 2013 12:58 am
Reply with quote

I have an Assembler main-program, invoked from JCL, which issues a SHOWCB Macro against a target VSAM ACB (either KSDS or ESDS), writes the number of records and max record length to a SYSPRINT report and also writes a record to an 80-byte sequential OUTFILE, with the following data -

01-08 - Target VSAM ACB/File DD Name (Passed as PARM)
09-09 - Blank
10-13 - File-Type (Returns literal "KSDS" or "ESDS")
14-14 - Blank
15-24 - Number of Records, PIC 9(10), Display Numeric
25-25 - Blank
26-30 - Max Record Length, PIC 9(05), Display Numeric
31-80 - Blanks or Future Use

The OUTFILE data-record can then be used as INPUT to the next step, such as SYSIN.

Send a private message if interested....
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 7
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts how to eliminate null indicator value... DB2 7
No new posts CA7 count with DATE variable CA Products 0
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
Search our Forums:

Back to Top