VSAM - Cluster

VSAM cluster is defined in JCL. JCL uses IDCAMS utility to create a cluster. IDCAMS is a utility, developed by IBM, for access method services. It is used to primarily define VSAM datasets.
The following syntax shows the main parameters which are grouped under Define Cluster, Data and Index.
.DEFINE CLUSTER (NAME(vsam-file-name)      -
BLOCKS(number)                             -
VOLUMES(volume-serial)                     -
[INDEXED / NONINDEXED / NUMBERED / LINEAR] -
RECSZ(average maximum)                     -
[FREESPACE(CI-Percentage,CA-Percentage)]   -
CISZ(number)                               -
[KEYS(length offset)]                      -
[READPW(password)]                         -
[FOR(days)|TO(date)]                       -
[UPDATEPW(password)]                       -
[REUSE / NOREUSE] )                        -
DATA                                       -
   (NAME(vsam-file-name.data))             -
INDEX                                      -
   (NAME(vsam-file-name.index))            -
CATALOG(catalog-name[/password]))            

Parameters at the CLUSTER level apply to the entire cluster. Parameters at the DATA or INDEX level apply only to the data or index component.
We will discuss each parameter in detail in the following table −
DEFINE CLUSTER
Define Cluster command is used to define a cluster and specify parameter attributes for the cluster and its components.
NAME
NAME specifies the name of VSAM file for which we are defining the cluster.
BLOCKS
Blocks specifies the number of blocks assigned for the cluster.
VOLUMES
Volumes specifies one or more volumes that will contain the cluster or component.
INDEXED / NONINDEXED / NUMBERED / LINEAR
This parameter can take three values INDEXED, NONINDEXED or NUMBERED depending upon the type of dataset we are creating. For key-sequenced(KSDS) files INDEXED option is used. For entry-sequenced(ESDS) files the NONINDEXED option is used. For relative-record(RRDS) files the NUMBERED option is required. For Linear(LDS) files the LINEAR option is required. The default value of this parameter is INDEXED. We will discuss more about KSDS, ESDS, RRDS and LDS in coming modules.
RECSZ
Record Size parameter has two values which are Average and Maximum record size. The Average specifies the average length of the logical records in the file and the Maximum denotes the length of the records.
FREESPACE
Freespace specifies the percentage of free space to reserve for the control intervals (CI) and control areas (CA) of the data component. The default value of this parameter is zero percentage.
CISZ
CISZ is known as Control interval size. It specifies the size of control intervals.
KEYS
Keys parameter is defined only in key-sequenced (KSDS) files. It specifies the length and offset of primary key from first column. The range of value of this parameter are from 1 to 255 bytes.
READPW
Value in READPW parameter specifies the password of read level.
FOR/TO
The value of this parameter specifies the amount of time in terms of date and days for retaining the file. The default value for this parameter is zero days.
UPDATEPW
Value in UPDATEPW parameter specifies the password of update level.
REUSE / NOREUSE
REUSE parameter allows clusters to be defined that may be reset to empty status without deleting and re-defining them.
DATA - NAME
The DATA part of the cluster contains the dataset name which contains the actual data of the file.
INDEX-NAME
The INDEX part of the cluster contains the primary key and the memory pointer for the corresponding record in the data part. It is defined when a Key Sequenced cluster is used.
CATALOG
Catalog parameter denotes the catalog under which the file will be defined. We will discuss about catalog separately in upcoming modules.
Following is a basic example to show how to define a cluster in JCL −
//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C
//STEP1  EXEC PGM = IDCAMS
//SYSPRINT DD  SYSOUT = *
//SYSIN    DD  *
   DEFINE CLUSTER (NAME(MY.VSAM.KSDSFILE)  -
   INDEXED                                 -
   RECSZ(80 80)                            -
   TRACKS(1,1)                             -
   KEYS(5  0)                              -
   CISZ(4096)                              -                            
   FREESPACE(3 3) )                        -
   DATA (NAME(MY.VSAM.KSDSFILE.DATA))      -
   INDEX (NAME(MY.VSAM.KSDSFILE.INDEX))
/*
If you will execute the above JCL on Mainframes server. It should execute with MAXCC = 0 and it will create MY.VSAM.KSDSFILE VSAM file.
To delete a VSAM file, the VSAM cluster needs to be deleted using IDCAMS utility. DELETE command removes the entry of the VSAM cluster from the catalog and optionally removes the file, thereby freeing up the space occupied by the object. If the VSAM data set is not expired then it will not be deleted. To delete such types of datasets use PURGE option.
DELETE data-set-name CLUSTER  
[ERASE / NOERASE] 
[FORCE / NOFORCE] 
[PURGE / NOPURGE] 
[SCRATCH / NOSCRATCH]

Above syntax shows the parameters which we can use with Delete statement. We will discuss each of them in detail in following table −
ERASE / NOERASE
ERASE option is specified to override the ERASE attribute specified for the object in the catalog. NOERASE option is taken by default.
FORCE / NOFORCE
FORCE option is specified to delete the SPACE and USERCATALOG even if they are not empty. NOFORCE option is taken by default.
PURGE / NOPURGE
PURGE option is used to delete the VSAM dataset if dataset has not expired. NOPURGE option is taken by default.
SCRATCH / NOSCRATCH
SCRATCH option is specified to remove the associated entry for the object from the Volume Table of Contents. It is mainly used for non-vsam datasets like GDGs. NOSCRATCH option is taken by default.
Following is a basic example to show how to delete a cluster in JCL −
//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C
//STEPNAME EXEC PGM = IDCAMS
//SYSPRINT DD  SYSOUT = *
//SYSIN    DD  *
   DELETE MY.VSAM.KSDSFILE CLUSTER
	PURGE
/*
If you will execute the above JCL on Mainframes server. It should execute with MAXCC = 0 and it will delete MY.VSAM.KSDSFILE VSAM file.

    8 Lectures 
     1 hours 

 Nishant Malik
 Print
 Add Notes
 Bookmark this page