VSAM vs Sequential Datasets

On the mainframe, data is stored in datasets. Two broad categories are sequential datasets and VSAM datasets. A sequential dataset is a stream of records in physical order: you read from the start to the end (or write that way). It can live on tape or DASD and is created with JCL. A VSAM dataset is a cluster (KSDS, ESDS, RRDS, or LDS) with internal structure—control intervals and, for KSDS, an index—and is created with IDCAMS and stored only on DASD. This page explains what we mean by "sequential dataset" versus "VSAM dataset," how they differ in storage, creation, and access, and when to choose one type over the other.

What Is a Sequential Dataset?

A sequential dataset is a dataset whose records are stored one after another in the order they were written. There is no index and no way to address a record by key or by a stored position value; the only way to reach a record is to read from the beginning (or from a position you have kept in the application). Sequential datasets are accessed with BSAM (Basic Sequential Access Method) or QSAM (Queued Sequential Access Method). QSAM is more common: it queues records in buffers and presents a simple read-next or write-next interface. BSAM works with physical blocks and is used when the program needs block-level control.

Sequential datasets have a record format (RECFM: F, V, U, etc.) and logical record length (LRECL) and block size (BLKSIZE). These are specified in the DCB when the dataset is allocated or when it is opened. Sequential datasets can be cataloged or uncataloged and can reside on DASD (disk) or on tape. Tape is a defining characteristic: if you need to ship data off to tape for archival or to another site, you use a sequential dataset. VSAM cannot use tape.

You create a new sequential dataset with JCL: a DD statement with DSN, DISP=(NEW,CATLG), SPACE= (in tracks, cylinders, or blocks), UNIT= (for DASD or tape), and optionally DCB=(RECFM=...,LRECL=...,BLKSIZE=...). No IDCAMS step is involved. Many utilities (IEBGENER, SORT, etc.) read and write sequential datasets. ISPF option 3.4 lets you browse and edit sequential datasets; it does not support VSAM.

What Is a VSAM Dataset?

A VSAM dataset is a cluster: one logical name that refers to one or two components (data, and for KSDS the index). The cluster has a type: KSDS (key-sequenced), ESDS (entry-sequenced), RRDS (relative record), or LDS (linear). Data is stored in control intervals (CIs) and control areas (CAs). For KSDS, an index maps key values to the CI containing the record, so the program can read or update by key. For ESDS, records are in write order and can be read by Relative Byte Address (RBA) or sequentially. For RRDS, records are in fixed-length slots and addressed by Relative Record Number (RRN). LDS has no record structure and is used by products like Db2.

VSAM datasets are always cataloged and exist only on DASD. They are created with the IDCAMS utility (DEFINE CLUSTER), not with JCL allocation. You do not specify RECFM in JCL for VSAM; record size is defined in DEFINE CLUSTER (RECORDSIZE). Because of the internal format, you cannot browse or edit a VSAM dataset with standard ISPF 3.4; you need a product that understands VSAM (e.g. File-AID, INSYNC, File Manager).

Comparison: Sequential vs VSAM Datasets

Sequential dataset vs VSAM dataset
AspectSequentialVSAM
DefinitionStream of records in order; no indexStructured (CIs, optional index); key or RBA or RRN
Storage mediaDASD or tapeDASD only
CreationJCL DD with SPACE and DCBIDCAMS DEFINE CLUSTER
AccessSequential only (read/write in order)Sequential, random by key, RBA, or RRN
Record format in JCLRECFM, LRECL, BLKSIZE in DCBNo RECFM; RECORDSIZE in DEFINE CLUSTER
ISPF browse/editYes (3.4 browse, edit)No; use File-AID, INSYNC, or similar
Insert/delete in middleNoYes (KSDS, RRDS); ESDS append only

Storage: Tape vs DASD

Sequential datasets can reside on tape or on DASD. Tape is used for archival, for shipping data between sites, and for large batch inputs or outputs that don't need random access. When you allocate a sequential dataset on tape, you use UNIT=TAPE or a tape unit name and the system writes records in order. VSAM does not support tape at all; the VSAM access method and control interval structure assume direct access (seek to a location). So if the requirement is "data must be on tape," the choice is a sequential dataset. If the requirement is "fast key-based access on disk," VSAM or a database is the right direction.

Creation and Tools

A new sequential dataset is created by JCL: a job step that allocates the dataset (often with IEFBR14 or a program that opens and closes the file). The DD statement specifies DSN, DISP=(NEW,CATLG), SPACE=, UNIT=, and optionally DCB. A new VSAM dataset is created by running IDCAMS with a DEFINE CLUSTER command. You specify the cluster name, type (INDEXED/NONINDEXED/NUMBERED/LINEAR), RECORDSIZE, and for KSDS KEYS and optionally FREESPACE. After that, application JCL references the cluster by DSN and DISP=SHR or OLD. So the creation path is different: JCL for sequential, IDCAMS for VSAM.

Browsing and editing also differ. Sequential datasets are standard files that ISPF 3.4 can open: you can browse, edit, search. VSAM datasets are not supported by standard ISPF browse/edit; you need a VSAM-aware tool. That can affect operations and support: if your team relies on ISPF to inspect or fix data, sequential is easier for that. VSAM requires either a dedicated tool or programmatic access (batch or online).

When to Choose a Sequential Dataset

Choose a sequential dataset when the access pattern is strictly one-way and in order, when the data must go to tape, when you want ISPF browse/edit, or when the data is a simple export/import or transfer format.

Situations that favor sequential datasets
SituationReason
Whole file read or written in order onceNo need for index or random access
Data must reside on tapeVSAM is DASD only
You need ISPF browse or editSequential files are supported; VSAM is not
Export/import or transfer to other systemsSequential (flat file) is the common interchange format
Log or audit trail, append-onlySequential or ESDS both work; sequential is simpler if no RBA need

When to Choose a VSAM Dataset

Choose a VSAM dataset when you need key-based or position-based access, when the same file is shared by batch and online, when you need inserts and deletes with space reuse, or when the data must stay on DASD with efficient random access.

Situations that favor VSAM datasets
SituationReason
Look up or update by keyKSDS provides indexed access
Access by position (RBA or RRN)ESDS supports RBA; RRDS supports RRN
Insert and delete with space reuseKSDS and RRDS support this; sequential does not
Batch and online share same fileVSAM SHAREOPTIONS allows multiple openers
Data must stay on DASD with fast key accessVSAM is designed for this

Access Methods in Brief

Sequential datasets use BSAM or QSAM. QSAM is the default for most programs: it handles blocking and buffering and presents logical records to the program. BSAM is used when the program needs to read or write physical blocks. VSAM datasets use the VSAM access method: the program opens the cluster and uses READ (by key, RBA, or RRN), WRITE, REWRITE, DELETE, and CLOSE. VSAM access methods cannot open a sequential dataset, and sequential access methods cannot open a VSAM cluster; the dataset type and the access method must match.

Summary of Choice Factors

  • Need tape or ISPF browse/edit? → Use a sequential dataset.
  • Only read or write the whole file in order? → Sequential is enough.
  • Need key-based or RBA/RRN access? → Use VSAM (or a database).
  • Need insert/delete in the middle with space reuse? → Use VSAM KSDS or RRDS.
  • Batch and online share one file? → VSAM with SHAREOPTIONS.
  • Creating the dataset? → JCL for sequential; IDCAMS for VSAM.

Explain Like I'm Five

A sequential dataset is like a long roll of paper: you start at the beginning and read or write one line after another. You can't jump to "line 100" without going through the first 99. A VSAM dataset is like a filing cabinet: you can open drawer 1, then 2, then 3 (sequential), or you can go straight to the drawer labeled "Smith" (key) or "drawer 5" (position). The roll of paper can be on a shelf (DASD) or on a tape reel; the filing cabinet only sits on the shelf. So: sequential = one direction, any medium; VSAM = jump by key or position, shelf (DASD) only.

Test Your Knowledge

Test Your Knowledge

1. Where can a sequential dataset reside?

  • DASD only
  • Tape only
  • DASD or tape
  • Neither

2. You need to browse the contents with ISPF 3.4. The file is VSAM. What applies?

  • ISPF browse works on VSAM
  • You need a tool like File-AID or INSYNC
  • VSAM is always read-only in ISPF
  • VSAM cannot be opened

3. How do you create a new sequential dataset?

  • IDCAMS DEFINE CLUSTER
  • JCL DD with DISP=(NEW,CATLG) and SPACE
  • REPRO
  • ALTER
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