Getting VSAM Information

VSAMSTAT

If you have VSAMSTAT installed, you can get basic VSAM space information by entering the line command VSAMSTAT against a VSAM component on a '3.4' ISPF listing. Results will typically look like below. The Total Free Space includes free space within the used portion of the dataset, either freespace coded for CI/CAs, or from deleted records. So Total Free Space is usually more than Allocated Space - Used Space.

SAP.VSAMCICS.INSACW21:
Allocated Space  :  30 tracks 2 Cylinders
Used Space       :  15 tracks   1 Cylinders
Total Space Free :  29 tracks  1 Cylinders

   EADM Advert

Accelerate DB2 Write with zHyperWrite and "EADM™ by Improving DB2 Logs Volumes Response Time:

LISTCAT

Probably the most useful VSAM information command is LISTCAT. The full syntax to list out a dataset is

TSO LISTCAT ENTRY(datasetname) ALL

Most people have installed a clist to shortcut this, but if your site hasn't got one, then add a member to any clist library in your logon procedure called LC (command 'tso lista' will display your logon libraries), then inside it, put

PROC 1 MEMBER
   LISTC ENT(&MEMBER) ALL
   EXIT CODE(0)

Now when you want to display the structure of a VSAM file, just use the line command 'LC' from a 3.4 file list. You will see lots of output from the command, some of which will look like

CISIZE-------------18432
CI/CA-----------------45
SPLITS-CI--------------0
SPLITS-CA--------------0
FREESPACE-%CI----------5
FREESPACE-%CA----------5

    GFS

This lot is about the physical chunks in the file. It has a 18k blocksize, which fits three to a track. The CA size is 1 cylinder, so there are 45 CIs in a CA. Both the CIs and the CAs have 5% freespace reserved for growth.

FREESPC----------3907584
HI-A-RBA---------4147200
HI-U-RBA----------829440
SPACE-TYPE------CYLINDER
SPACE-PRI--------------5
SPACE-SEC--------------1

Allocation information. The file is allocated in Cylinders, and has a 5 cylinder primary and a 1 cylinder secondary. It can have up to 119 extents on a single volume, and up to 255 if it can span volumes. The High-Used-Relative Byte Address is only about 800k, while the High-Allocated-Relative Byte Address is about 4m, so the file has lots of free space available for growth

INDEX:
  LEVELS-----------------1

Single level index, so no performance issues

How can you tell if a VSAM file is full?
Is the HI-U-RBA is the same as the HI-A-RBA?
No - the file is not full
Yes - the allocated part of the file is full but it may be able to get more extents.
 Does the file have between 251 and 255 extents?
  Yes - the file is definitely full.
  No - Is there room on the volume for the file to get another extent?
    ;Yes - the file has room to expand so it is not full
    No - does the file have any unused candidate volumes defined?
     Yes - the file can expand onto another volume
     No - The file is full.

Your options are to re-organise it to give it a bigger allocation, or to add candidate volumes. A reorg. is disruptive. You can add candidate volumes in flight, but you must close the file before they are picked up.

EXAMINE

Examine is used to check that the index and data components of a KSDS are synchronised.
Typical syntax is

EXAMINE NAME(SAP.PROD.ISF04) -
  INDEXTEST DATATEST -
  ERRORLIMIT(50)

VERIFY

Verify is used to check for, and fix, VSAM files which have not been closed properly after an error. The command basically adds correct End-Of-Data records to the file. Syntax is

VERIFY DS(TPXP.MONVAZP.EMXSRTV)

Creating a KSDS file

DEFINE CLUSTER(NAME(XAB1.BATRCICS.U38)-
     MODEL(XAB1.WKLDCICS.U38)-
     MGMTCLAS(MONTH6)) -
  DATA(NAME(XAB1.BATRCICS.U38.DATA)-
  CYL(20 20) -
   VOLUMES(* * * * *)) -
   INDEX(NAME(XAB1.BATRCICS.U38.INDEX)-
   TRK(15 15))

These IDCAMS statements will create a new VSAM KSDS, XAB1.BATRCICS.U38, modeled on an existing KSDS, XAB1.WKLDCICS.U38, but with some attributes overridden. The new file will get a 'Month6' management class and the space allocations are changed. The dataset will be SMS managed, but the VOLUMES statement allows it to span over 5 non-specific volumes. The DATA and INDEX components are specifically named to prevent IDCAMS from allocating default names.

Initialising VSAM files

VSAM files often need to be initialised with high or low values before data can be added by programs. To initialise a VSAM file copy the JCL below to a PDS job library, then switch into HEX mode by typing 'HEX' on the command line, then after the INDD line type two rows of zeros as shown below. Note that x'40' is a blank space, '00' is hex low values. For high values, type in 'FF'.

000240 //INDD DD *
      66CDCC44CC4544444444444444444444
      11954400440C00000000000000000000
---------------------------------------
000284
      00000000000000000004444444444444
      00000000000000000000000000000000

Type HEX OFF on the command line and you will see the JCL as below. The x'00' low values looks exactly like the x'40' blank spaces, and so does x'FF', which can be confusing. You need HEX ON to see what is really there.

//STEP0001  EXEC PGM=IDCAMS
//SYSPRINT  DD  SYSOUT=*
//SYSUDUMP  DD  SYSOUT=*
//INDD     DD *

//OTDD     DD DSN=dataset.name,DISP=OLD
//SYSIN     DD *
REPRO  INFILE(INDD) OUTFILE(OTDD)

REPRO

The REPRO command is used to copy data between files as shown in the example above. The INFILE and OUTFILE parameters point to DD statements, and the exact file names are then placed in the JCL. In the example above, //INDD DD * means the data to be copied is placed just below this line in the JCL. You could also use
REPRO INDATASET(datasetname) OUTDATASET(datasetname)
parameters and code the file names in the SYSIN DD statement, but I prefer the DD method.

If you wanted to copy some of the data from a KSDS, you can also specify start and end keys like this

REPRO INFILE(INDD) -
   OUTFILE(OTDD) -
    FROMKEY(AARDVARK) -
   TOKEY(BANANA)

EXPORT/IMPORT

REPRO can be used for VSAM backups, but EXPORT is much better as an export includes the data required to recreate a file, whereas with REPRO you need to know the file definition data so you can create it manually. Typical EXPORT commands could look like

EXPORT -
   CICP1.XCREDBG.ESDS -
   OUTFILE(DDOUT) -
   PURGE

EXPORT -
   CICP1.XCREDBG.ESDS -
   OUTFILE(DDOUT) -
   TEMPORARY

In the first example, the dataset is copied to a file specified in the DDOUT DD statement. This could be either a disk or a tape file. Once the export in completed the original file will be deleted. In the second example, the source file is not deleted.
The data can then be recreated with an IMPORT command, and in this case, recreated with a new name.

IMPORT -
   INFILE(DDIN) -
   OUTDATASET(CICP1.TEST.ESDS) -
   OBJECTS( -
   (CICP1.XCREDBG.ESDS
    NEWNAME(CICP1.TEST.ESDS)) -
   (CICP1.XCREDBG.ESDS.DATA -
    NEWNAME(CICP1.TEST.ESDS.DATA)))

back to top