VSAM - Cluster


Advertisements


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.No Parameters with Description
1

DEFINE CLUSTER

Define Cluster command is used to define a cluster and specify parameter attributes for the cluster and its components.

2

NAME

NAME specifies the name of VSAM file for which we are defining the cluster.

3

BLOCKS

Blocks specifies the number of blocks assigned for the cluster.

4

VOLUMES

Volumes specifies one or more volumes that will contain the cluster or component.

5

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.

6

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.

7

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.

8

CISZ

CISZ is known as Control interval size. It specifies the size of control intervals.

9

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.

10

READPW

Value in READPW parameter specifies the password of read level.

11

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.

12

UPDATEPW

Value in UPDATEPW parameter specifies the password of update level.

13

REUSE / NOREUSE

REUSE parameter allows clusters to be defined that may be reset to empty status without deleting and re-defining them.

14

DATA - NAME

The DATA part of the cluster contains the dataset name which contains the actual data of the file.

15

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.

16

CATALOG

Catalog 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.No Parameters with Description
1

ERASE / NOERASE

ERASE option is specified to override the ERASE attribute specified for the object in the catalog. NOERASE option is taken by default.

2

FORCE / NOFORCE

FORCE option is specified to delete the SPACE and USERCATALOG even if they are not empty. NOFORCE option is taken by default.

3

PURGE / NOPURGE

PURGE option is used to delete the VSAM dataset if dataset has not expired. NOPURGE option is taken by default.

4

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.

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.



Advertisements