gtpa2m33Application Programming

VSAM Concepts

VSAM is an IBM licensed program; as an access method service, it provides fast storage and retrieval of data. Records are stored in control intervals; that is, in the block on the disk that VSAM uses to store data records and control information that describes the records. Records are ordered by key values in a key field or by when they were stored.

For access to a keyed data set, also known as a key-sequenced data set (KSDS), you specify a key value; for access to a nonkeyed data set, also known as an entry-sequenced data set (ESDS) or sequential data set, you specify a relative byte address (RBA). A variation of keyed data set access is known as a relative record data set (RRDS), which is comprised entirely of fixed-length records; the record number is handled like a key.

VSAM maintains the concept of a logical next record and logical previous record interface to provide database scans and searches. Keyed positioning is also available to begin scans either at the beginning or in the middle of a data set, including a KSDS.

A KSDS has two data set components: a data component and an index component. The VSAM index of a highly volatile file may be very complex, requiring several levels of indexes. These layers are known as the index set. The index set points to the lowest level index, called the sequence set. For performance reasons, the sequence set typically resides on the same cylinder as the data control intervals to which it refers in the data component. The keys in the index set are always compressed. VSAM supports alternate indexes to provide alternate access to data; for example, the prime index key to a database could be an account number, while the alternate key could be a customer name.

The three ways to access data in a VSAM data set are:

Figure 34 shows the typical layout of a key-sequenced data set.

Figure 34. Layout of a Key-Sequenced Data Set


VSAM is controlled by a set of macros to manage data (OPEN, POINT, GET, PUT, ERASE, ENDREQ, and CLOSE) and a set of macros to manage control blocks (GENCB, TESTCB, SHOWCB, MODCB). These are described in MVS/XA VSAM Administration: Macro Instruction Reference.

Typically, an application requests VSAM services by running a predefined sequence of macro calls. The dialog is controlled by two major control blocks: the access method control block (ACB) and the request parameter list (RPL). These control blocks describe the characteristics of the data set, the type of access that is required, and the status of active requests. They are created using the TPF GENCB macro and are passed with each VSAM data request.

The dialog between VSAM and an application to read a record is structured as follows:

  1. Enter the GENCB macro to create an ACB and an RPL.
  2. Enter the OPEN macro to connect to a database.
  3. Enter the GET macro to read a data record, followed by the CHECK macro to wait for results of the read.
  4. Process the data record.
  5. Enter the ENDREQ and CLOSE macros to end the request and disconnect from the database.