VSAM Structure
In this Mainframe tutorial, you will learn about VSAM Structure, four major areas of VSAM structure, what is VSAM cluster, VSAM components, Defining VSAM cluster and Example for defining VSAM clusters.
There are four major areas in the structure of VSAM. They are:
- The Master catalog
- The User catalog
- The Data space
- The file also called as cluster
What is VSAM Cluster?
VSAM dataset which we have seen in detail in our earlier section when defined logically takes up the form as a VSAM cluster. Before proceeding to see about VSAM cluster it is very important to know primarily what a cluster is. A cluster nothing but a association of the index, sequence set and data portions of the dataset. The operating system takes the responsibility of giving program access to the cluster by which access to given to all parts of the dataset simultaneously. The space occupied by a VSAM cluster is divided into contiguous areas called control intervals (CI) and about this concept we have seen in detail in our earlier section.
There are two main components present in a VSAM cluster and they are as given below:
• The data component
• The index component
Data Component of VSAM Cluster: Data records are present in the data component of a VSAM cluster.
Index Component of VSAM Cluster: Index records are present in the index component of a VSAM key-sequenced cluster.
Defining VSAM cluster:
The command used for defining the VSAM cluster is DEFINE CLUSTER which defines the entry name, name of the catalog to contain this definition and its password, Organization detail like sequential, indexed, or relative, Device and volumes that the data set will occupy, Space required for the data set, Record size and control interval sizes, for future access Passwords if needed.
The syntax of this command is as below:
DEFINE CLUSTER (NAME(entryname)
BLOCKS(number)
VOLUMES(volser)
RECORDSIZE(average maximum)
[INDEXED|NONINDEXED|NUMBERED]
[FREESPACE(cipercent capercent)]
[KEYS(length offset)]
[READPW(password)]
[FOR(days)|TO(date)]
[UPDATEPW(password)])
[CATALOG(catname[/password]
In the above syntax
NAME attribute denotes the entry name which is the name of the cluster to be defined. The naming conventions or the rules for naming this attribute takes up the same rules and convention as defined for naming a catalog.
BLOCKS attribute BLOCKS denotes a number and the corresponding number specifies the number of blocks for the cluster.
VOLUMES parameter denotes the volumes to contain the cluster.
RECORDSIZE parameter has two values:
- average
- maximum
The average specifies the average length of the logical records in the file and the maximum denotes the length of the records.
INDEXED|NONINDEXED|NUMBERED parameter can take three values INDEXED, NONINDEXED or NUMBERED depending upon the type of dataset. That is the INDEXED option is given if it is key-sequenced files, for entry-sequenced files the NONINDEXED option and for relative-record files the NUMBERED option is required. The default value of this parameter is INDEXED.
FREESPACE parameter specifies the amount of free space per control interval and per control area for a key-sequenced file. The value of this parameter is specified in percentage. The default value of this parameter is 0 percentage.
KEYS The value of this parameter specifies the size of the key field which in other words depicts the length and the offset of the key from the beginning of the record. The range of value that can be taken by this parameter are from 1 to 255 bytes. It should be noted that the parameter takes its presence only in key-sequenced files.
READPW The value of this parameter denotes the password of read level.
UPDATEPW The value of this parameter denotes the password of update level.
FOR|TO The value of this parameter specifies the amount of time for retaining the file. The default value taken by this parameter is 0 days.
CATALOG parameter denotes the catalog under which this file will be defined.
When the VSAM cluster is defined by using the DEFINE CLUSTER command as above an entry gets created in an integrated VSAM catalog.
Example for defining VSAM clusters
DEFINE CLUSTER-
(NAME(SECOND.EXFORSYS)-
VOLUMES(DCE001)-
FREESPACE(20 5)-
BLOCKS(80)-
INDEXED-
KEYS(5 15)-
RECORDSIZE (20 50)-
CATALOG(T1.E2.Test.CATALOG/MASTER)
In the above example cluster SECOND.EXFORSYS is defined, which allocates DCE001 volumes for the corresponding cluster with 20 percentage of free area per control interval and 5% of free area per control area for the cluster. The above cluster SECOND.EXFORSYS in example is defined to occupy 80 blocks and the type is defined as INDEXED which is denoted for key-sequenced files. Being INDEXED the default value of the parameter one need not define this value also. The length of the key field is 20 characters and this field is placed at an offset of 16 characters from the beginning of the record as defined above. Note: For keys, the offset starts from ‘0’. This means that the first character in a records will have the offset ‘0’ and the second character will have an offset ‘1’. The average length of the logical records in the file for the cluster defined takes the value of 20 and the allowable maximum length of the record in the file for the cluster defined is 50.The file is placed in the catalogue T1.E2.Test.CATALOG/MASTER.