View previous topic :: View next topic
|
Author |
Message |
gnaveenkumar.99
New User
Joined: 21 Sep 2011 Posts: 8 Location: India
|
|
|
|
Whats the best way to count the number of records in a VSAM File? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Whilst reading the data for another purpose. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Gary McDowell
Active User
Joined: 15 Oct 2012 Posts: 139 Location: USA
|
|
|
|
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 |
|
|
Pete Wilson
Active Member
Joined: 31 Dec 2009 Posts: 592 Location: London
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
ICETOOL COUNT will count records without having to specify a dummy dataset.
However, TS seems to have wondered off... |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
|