VSAM - Commands



VSAM commands are used to perform certain operations on VSAM datasets. Following are the most useful VSAM commands −

  • Alter
  • Repro
  • Listcat
  • Examine
  • Verify

Alter

ALTER command is used to modify VSAM file attributes. We can change the attributes of VSAM file which we have mentioned in VSAM Cluster definition. Following is the syntax to change the attributes −

ALTER  file-cluster-name [password] 
   [ADDVOLUMES(volume-serial)] 
   [BUFFERSPACE(size)] 
   [EMPTY / NOEMPTY] 
   [ERASE / NOERASE] 
   [FREESPACE(CI-percentage CA-percentage)] 
   [KEYS(length offset)] 
   [NEWNAME(new-name)] 
   [RECORDSIZE(average maximum)] 
   [REMOVEVOLUMES(volume-serial)] 
   [SCRATCH / NOSCRATCH] 
   [TO(date) / FOR(days)] 
   [UPGRADE / NOUPGRADE] 
   [CATALOG(catalog-name [password]]

Above syntax shows which parameters we can alter in an existing VSAM cluster. The parameter description remains the same as mentioned in VSAM - Cluster module.

Example

Following example shows how to use ALTER command to increase Freespace, to add more volumes and to Alter Keys −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C
//STEP1  EXEC PGM = IDCAMS
//SYSPRINT DD  SYSOUT = *
//SYSIN DD  *
   ALTER  MY.VSAM.KSDSFILE 
   [ADDVOLUMES(2)] 
   [FREESPACE(6 6)] 
   [KEYS(10 2)] 
/*

If you will execute the above JCL on Mainframes server. It should execute with MAXCC = 0 and it will alter the Freespace, Volumes and Keys.

Repro

REPRO command is used to load data into VSAM dataset. It is also used to copy data from one VSAM data set to another. We can use this command to copy data from sequential file to VSAM file. IDCAMS utility uses REPRO command to load the datasets.

REPRO INFILE(in-ddname) 
   OUTFILE(out-ddname) 

In the above syntax, the in-ddname is DD name for the Input Dataset which is having records. The out-ddname is the DD name for the Output Dataset, where the input datasets records will be copied.

Example

Following example shows how to copy records from one dataset to another VSAM dataset −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C
//STEP1  EXEC PGM = IDCAMS
//IN  DD DSN = MY.VSAM.KSDSFILE,DISP = SHR
//OUT DD DSN = MY.VSAM1.KSDSFILE,DISP = SHR
//SYSPRINT DD  SYSOUT = *
//SYSIN DD  *
   REPRO INFILE(IN) 
      OUTFILE(OUT)
/*

If you will execute the above JCL on Mainframes server. It should execute with MAXCC = 0 and it will copy all the records from MY.VSAM.KSDSFILE to MY.VSAM1.KSDSFILE VSAM file.

Listcat

LISTCAT command is used to get the catalog details of a VSAM dataset. Listcat command provides following information about VSAM datasets −

  • SMS Information
  • RLS Information
  • Volume Information
  • Sphere Information
  • Allocation Information
  • Dataset Attributes
LISTCAT ENTRY(vsam-file-name) ALL

In the above syntax, vsam-file-name is the VSAM dataset name for which we need all the information. ALL keyword is specified to get all catalog details.

Example

Following example shows how to fetch all the details using Listcat command for a VSAM dataset −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C
//STEP1  EXEC PGM = IDCAMS
//SYSPRINT DD  SYSOUT = *
//SYSIN DD  *
   LISTCAT ENTRY(MY.VSAM.KSDSFILE) 
   ALL 
/*

If you will execute the above JCL on Mainframes server. It should execute with MAXCC = 0 and it will show all the catalog details about MY.VSAM.KSDSFILE dataset.

Examine

Examine command is used to check the structural integrity of a key-sequenced data set cluster. It checks for index and data components and if any problem is found, the error messages are sent spool. You can check any of the IDCxxxxx messages.

EXAMINE NAME(vsam-ksds-name) -                                    
   INDEXTEST DATATEST -                  
   ERRORLIMIT(50)

In the above syntax, vsam-ksds-name is the VSAM dataset name for which we need to examine index and data part of VSAM cluster.

Example

Following example shows how to check whether Index and Data part of KSDS dataset are synchronized or not −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C
//STEP1  EXEC PGM = IDCAMS
//SYSPRINT DD  SYSOUT = *
//SYSIN DD  *
   EXAMINE NAME(MY.VSAM.KSDSFILE) -                                    
   INDEXTEST DATATEST -                  
   ERRORLIMIT(50)
/*

If you will execute the above JCL on Mainframes server. It should execute with MAXCC = 0 and it will show all problems with the VSAM data set in one of the IDCxxxxx messages in spool.

Verify

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

VERIFY DS(vsam-file-name)                                  

In the above syntax, vsam-file-name is the VSAM dataset name for which we need to check the errors.

Example

Following example shows how to check and fix errors in VSAM dataset −

//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C
//STEP1  EXEC PGM = IDCAMS
//SYSPRINT DD  SYSOUT = *
//SYSIN DD  *
   VERIFY DS(MY.VSAM.KSDSFILE)                                  
/*

If you will execute the above JCL on Mainframes server. It should execute with MAXCC = 0 and it will fix the errors in VSAM dataset.

Advertisements