What is VSAM?

VSAM (Virtual Storage Access Method) is IBM's access method for organizing and retrieving data on mainframe direct-access storage (DASD). It is both a way to store data and the software that manages how programs read and write that data. When someone says "VSAM file," they usually mean a dataset that was created with the VSAM access method and is managed by VSAM code in the operating system. This page defines what VSAM is, how it fits into the mainframe, and how it differs from other ways of storing data.

Definition of VSAM

Formally, VSAM is an access method: it defines how logical records are placed on DASD and how the system retrieves or updates them. "Virtual Storage" refers to the fact that VSAM uses the system's virtual memory and buffers to move data between disk and the program. "Access Method" means it sits between your application (e.g. COBOL, PL/I) and the physical I/O layer, handling blocking, indexing, and space management so the programmer does not have to.

A VSAM dataset is a named object in the catalog. It has a specific structure (one of four types: KSDS, ESDS, RRDS, LDS) and attributes such as record size, key location, and space allocation. The data is stored in a format that only VSAM interprets: control intervals, control areas, and for KSDS an index component. You cannot open a VSAM dataset with a generic file editor the way you might a sequential flat file; programs use language-specific file APIs (e.g. COBOL SELECT/READ/WRITE) that call into VSAM.

VSAM in the Mainframe Stack

On z/OS, your program runs in an address space and issues READ or WRITE for a file. The file is connected to a DD name in JCL, which points to a VSAM cluster. The request goes to VSAM, which uses the catalog to find the dataset, uses buffers and (for KSDS) the index to locate the record, and performs the I/O. So VSAM sits above the physical device layer and below the application. Other access methods on the mainframe include QSAM (sequential), BSAM (basic sequential), and BDAM (basic direct); VSAM is the one that offers integrated indexing, keyed access, and the four dataset types in one framework.

What VSAM Is Not

It helps to be clear about what VSAM is not. VSAM is not a relational database: it has no SQL, no tables in the SQL sense, and no query optimizer. It is not a replacement for Db2 when you need complex queries, joins, or transactions across many tables. VSAM is not a general-purpose file system like z/OS UNIX File System; it is for record-oriented datasets with a fixed or variable record layout. VSAM is also not something you create with JCL allocation (DISP=NEW, SPACE=...); those parameters are for non-VSAM datasets. VSAM datasets are created with the IDCAMS utility.

The Four VSAM Dataset Types at a Glance

Part of "what is VSAM" is knowing the four kinds of datasets it supports. Each type determines how records are stored and how you address them.

VSAM dataset types
TypeFull nameHow you address records
KSDSKey Sequenced Data SetBy key value (e.g. customer ID); records stored in key order
ESDSEntry Sequenced Data SetBy Relative Byte Address (RBA) or sequential order; append-only
RRDSRelative Record Data SetBy relative record number (slot 1, 2, 3, ...)
LDSLinear Data SetBy byte offset; no record structure, used by Db2 and system

Where VSAM Is Used Today

VSAM is still widely used in production. Many CICS applications use VSAM files for master and transaction data. Batch jobs read and update VSAM KSDS or ESDS files. IMS uses VSAM for certain datasets. Db2 uses VSAM internally: for example, linear data sets (LDS) for tablespace and index space storage, and key-sequenced VSAM for the bootstrap dataset. So even when the application uses Db2, VSAM may be underneath. Legacy applications that have run for decades often rely on VSAM, and new mainframe development still chooses VSAM when the requirement is key-based or position-based file access without a full database.

Key Terms

  • Cluster — The logical VSAM dataset; for KSDS it consists of a data component and an index component.
  • Control interval (CI) — The unit of data VSAM transfers between disk and memory; typically 4KB.
  • Control area (CA) — A group of control intervals; used for space allocation and splits.
  • IDCAMS — Access Method Services; the utility used to define, alter, delete, and copy VSAM objects.
  • RBA — Relative Byte Address; the byte offset of a record from the start of the dataset (used in ESDS).
  • RRN — Relative Record Number; the slot number in an RRDS (1, 2, 3, ...).

Tutorial: Verifying a VSAM Dataset Exists

You have a dataset name and want to confirm it is a VSAM dataset and see its attributes. Use IDCAMS with the LISTCAT command.

jcl
1
2
3
4
5
//LISTCAT EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * LISTCAT ENTRIES(MY.VSAM.DATASET) ALL /*

LISTCAT lists catalog information. ENTRIES limits the listing to the specified name; ALL requests full attributes including cluster type, record size, key information, and space. The output appears on SYSPRINT. If the dataset does not exist or is not cataloged, IDCAMS reports an error. This confirms that the object is VSAM (cataloged as a cluster) and shows what type (CLUSTER, DATA, INDEX for KSDS).

Explain Like I'm Five: What Is VSAM?

Think of a library. Some shelves are in order by book number (like "position 1, 2, 3"). Others are in order by the author's name on the spine. VSAM is the mainframe's system for organizing data so the computer can find a "record" (a row of information) either by its position or by a key (like a customer number). The library has special rules: books go in fixed-size boxes (control intervals), and there's a catalog that knows where each box is. VSAM is that set of rules and the program that enforces them. You don't build the shelves with normal file commands; you use a special tool (IDCAMS) to define them, and then your programs just ask for a record by key or position.

Test Your Knowledge

Test Your Knowledge

1. What does the "V" in VSAM stand for?

  • Variable
  • Virtual
  • Volume
  • Vector

2. Which component is used to create VSAM datasets?

  • JCL DISP=NEW
  • IDCAMS
  • IEBGENER
  • ISPF 3.2

3. Which VSAM type is organized by key?

  • ESDS
  • RRDS
  • LDS
  • KSDS
Published
Updated
Read time4 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: IBM z/OS 2.5 documentationSources: IBM DFSMS Access Method Services, z/OS VSAM documentationApplies to: z/OS 2.5