VSAM – Cluster

  • Post author:
  • Post category:VSAM
  • Post comments:1 Comment

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.

Defining a Cluster

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 −

Sr.NoParameters with Description
1DEFINE CLUSTERDefine Cluster command is used to define a cluster and specify parameter attributes for the cluster and its components.
2NAMENAME specifies the name of VSAM file for which we are defining the cluster.
3BLOCKSBlocks specifies the number of blocks assigned for the cluster.
4VOLUMESVolumes specifies one or more volumes that will contain the cluster or component.
5INDEXED / NONINDEXED / NUMBERED / LINEARThis 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.
6RECSZRecord 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.
7FREESPACEFreespace 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.
8CISZCISZ is known as Control interval size. It specifies the size of control intervals.
9KEYSKeys 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.
10READPWValue in READPW parameter specifies the password of read level.
11FOR/TOThe 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.
12UPDATEPWValue in UPDATEPW parameter specifies the password of update level.
13REUSE / NOREUSEREUSE parameter allows clusters to be defined that may be reset to empty status without deleting and re-defining them.
14DATA – NAMEThe DATA part of the cluster contains the dataset name which contains the actual data of the file.
15INDEX-NAMEThe 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.
16CATALOGCatalog parameter denotes the catalog under which the file will be defined. We will discuss about catalog separately in upcoming modules.

Example

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.

Deleting a Cluster

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 −

Sr.NoParameters with Description
1ERASE / NOERASEERASE option is specified to override the ERASE attribute specified for the object in the catalog. NOERASE option is taken by default.
2FORCE / NOFORCEFORCE option is specified to delete the SPACE and USERCATALOG even if they are not empty. NOFORCE option is taken by default.
3PURGE / NOPURGEPURGE option is used to delete the VSAM dataset if dataset has not expired. NOPURGE option is taken by default.
4SCRATCH / NOSCRATCHSCRATCH 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.

Example

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.

This Post Has One Comment

Leave a Reply