VSAM Concepts

VSAMVSAM stands for Virtual Storage Access Method. As the name implies, it is a method by which different type of datasets can be accessed quickly and efficiently. It is used to organize, store, catalog, retrieve and delete datasets. The access method will work only in these two conditions: • DATA • Method of getting the data To understand VSAM, the following things everyone should know: • We need to see how data is organized in VSAM dataset • We need to understand how to use the utility that are available in AMS. • We need to know how to use the power of VSAM in COBOL.Advantages of VSAM: • Data can be accessed faster because of the way VSAM dataset is organized. • Records are physically deleted from disk (instead of being logically removed). • Records can be inserted in more efficient manner.

Disadvantages of VSAM: • VSAM data sets require more storage space than other type of datasets. This is because VSAM datasets carry control information in them, in addition to actual data that they are comprised of.

DATA ORGANISATION IN VSAM DATASETS: VSAM supports four types of file organizations: • Key Sequenced Data Sets (KSDS) • Entry Sequenced Data sets (ESDS) • Relative Record Data Sets (RRDS) • Linear Data Sets (LDS) The efficiency with which the data is accessed depends upon the data that is organized in these VSAM files.

Concepts: VSAM was, by several accounts, intended to replace all of the earlier data management systems in use by IBM’s operating systems. Conventional (non-VSAM) access methods generally provide only a single type of dataset organization. VSAM provides three: Key Sequenced Data Set (KSDS), where each record is identified for access by specifying its key value – a sequence of characters embedded in each data record which uniquely identify that record from all other records in the dataset. KSDS datasets are similar to Indexed Sequential Access Method (ISAM) datasets, with many of the same characteristics, but also having distinct advantages over ISAM. Entry Sequenced Data Set (ESDS), where each record is identified for access by specifying its physical location – the byte address of the first data byte of each record in relationship to the beginning of the dataset. ESDS datasets are similar to Basic Sequential Access Methid (BSAM) or Queued Sequential Access Method (QSAM) datasets. Relative Record Data Set (RRDS), where each record is identified for access by specifying its record number – the sequence number relative to the first record in the dataset. RRDS datasets are similar to Basic Direct Access Method (BDAM) datasets. VSAM datasets are frequently referred to as clusters. A KSDS cluster consists of two physical parts, an index component, and a data component. ESDS and RRDS clusters consist of only a single component, the data component.

KSDS Cluster Components Each record in the data component of a KSDS cluster contains a key field, which must be the same number of characters and occur in the same relative position in each record. The records are stored in the data component in logical sequence based upon their key field value. The index component of the KSDS cluster contains the list of key values for the records in the cluster with pointers to the corresponding records in the data component. The records in a KSDS may be accessed sequentially, in order by key value, or directly, by supplying the key value of the desired record. The records of a KSDS cluster may be fixed length or variable length. Records may be added or deleted at any point within a KSDS cluster, and the affected record is inserted or removed, and the surrounding records will be reorganized as required to maintain the correct logical sequence.

ESDS Cluster Components The records in an ESDS cluster are stored in the order in which they are entered into the dataset. Each record is referenced by its relative byte address (RBA). In an ESDS dataset of 100 byte records, the RBA of the first record is 0, the RBA of the second record is 100, the RBA of the third record is 200, etc. The records in an ESDS may be accessed sequentially, in order by RBA value, or directly, by supplying the RBA of the desired record. The records of an ESDS cluster may be fixed length or variable length. Records may not be deleted from an ESDS cluster, and they may only be added (appended) to the end of the dataset, following records previously written.

RRDS Cluster Components The records in an RRDS cluster are stored in fixed length slots. Each record is referenced by the number of its slot, which is a number varying from 1 to the maximum number of records which may be contained in the dataset. The records in an RRDS cluster may be accessed sequentially, in relative record number order, or directly, by supplying the relative record number of the desired record. The records of an RRDS cluster must be of fixed length. Records may be added to an RRDS cluster by writing a new record’s data into an empty slot, and records may be deleted from an RRDS cluster, thereby leaving an empty slot where the record that was deleted was previously stored.

Control Intervals In non-VSAM data management methods, the unit of data that is moved between memory and the storage device is defined by the block. In VSAM, the unit of data that is transferred in each physical I/O operation is defined as a control interval. A control interval contains records, control information, and (in the case of KSDS clusters) possibly free space which may later be used to contain inserted records. When a VSAM dataset is loaded, control intervals are created and records are written into them. With KSDS clusters, the entire control interval is usually not filled. Some percentage of free space is left available for expansion. With ESDS clusters, each control interval is completely filled before records are written into the next control interval in sequence. With RRDS clusters, control intervals are filled with fixed-length slots, each containing either an active record or a dummy record. Slots containing dummy records are available for use when new records are added to the dataset.

Control Areas Control intervals are grouped together into control areas. The rules used for filling and writing control areas are similar to those which apply for control intervals. For ESDS and RRDS clusters, control areas are filled with control intervals that contain records. For KSDS clusters, some of the control intervals in each control area may consist entirely of free space that can be used for dataset expansion.

VSAM Catalogs When a non-VSAM dataset is created, the user has the option, by means of the DISP=(,CATLG) JCL entry, of creating a catalog entry for the dataset. The catalog keeps track of the unit and volume on which the dataset resides and can be used for later retrieval of the dataset. With VSAM datasets, creation of a catalog entry to record the unit and volume, as well as many other characteristics of the dataset, is not optional. Prior to VSAM, catalog entries for non-VSAM datasets were contained in OS CVOLS (operating system control volumes). VSAM maintains its own catalog, which is itself a KSDS cluster, into which catalog entries describing VSAM clusters are recorded. The same VSAM catalog may also be used to contain the catalog entries for non-VSAM datasets.

VSAM ERROR PROCESSING: Because the way VSAM handles error condions, many I/O errors that cause the COBOL program to abend whne you use non VSAM access methods don't cause an abend when you use VSAM.  

File Status Code OPEN CLOSE READ WRITE REWRITE DELETE SATART Recommended action
0 File successfully opened File successfully closed File successfully read File successfully written File successfully rewritten File successfully deleted Successful Completion Continue processing
2     Vaild duplicate alternate key Vaild duplicate alternate key Vaild duplicate alternate key     Continue processing
10     End of file reached         Normal AT END processing
21       Record out of sequence (sequential access only)       Print error message and continue
22       Duplicate key       Print error message and continue
23     Record no found     Record no found Specified key not found Print error message and continue
24       No more Space allocated to file       Terminate the job
30 Uncorrectable I/O error Uncorrectable I/O error Uncorrectable I/O error Uncorrectable I/O error Uncorrectable I/O error Uncorrectable I/O error Uncorrectable I/O error Terminate the job
90 Unusable file;possibly an empty opened as INPUT as I-O VSAM logic error VSAM logic error VSAM logic error VSAM logic error VSAM logic error VSAM logic error Terminate the job
91 Password Failure             Terminate the job
92 File already opened File not open File not open or end of file already reached File not open ; incorrect key for EXTEND file File no open;no previous READ File no open;no previous READ(sequential access) Invalid request;probably file not open Terminate the job
93 Not enough storage for VSAM task, or file contention problem Not enough storage for VSAM task, or file contention problem Not enough storage for VSAM task, or file contention problem Not enough storage for VSAM task, or file contention problem Not enough storage for VSAM task, or file contention problem Not enough storage for VSAM task, or file contention problem Not enough storage for VSAM task, or file contention problem Terminate the job
95 Conflicting the attributes             Terminate the job
96 No DD or DLBL statement             Terminate the job
97 File not closed by previous job             Terminate the job

     

Share your comment

%d bloggers like this: