VSAM vs Sequential Datasets

On the mainframe, "sequential" usually means datasets accessed with BSAM (Basic Sequential Access Method) or QSAM (Queued Sequential Access Method). These are simple streams of blocks: you read or write records in order. VSAM is different: it has control intervals, optional indexing, and supports random access by key or position. This page compares VSAM and sequential datasets so you know when to use each and how they differ in structure, creation, and use.

Sequential Datasets: BSAM and QSAM

Sequential datasets are stored as a sequence of blocks on DASD or tape. The record format (RECFM: F, V, U, etc.) and logical record length (LRECL) and block size (BLKSIZE) define how records are packed. BSAM gives the program more control over blocking; QSAM queues records and handles blocking automatically. In both cases, access is sequential: read next, write next. There is no index and no key-based retrieval. You allocate a new sequential dataset with JCL: DD with DISP=(NEW,CATLG), SPACE=..., and optionally DCB=(RECFM=...,LRECL=...,BLKSIZE=...). The dataset can be cataloged or not and can be on tape.

VSAM: Structure and Access

VSAM datasets are built from control intervals (CIs) and, for KSDS, an index. They are always cataloged and exist only on DASD. You create them with IDCAMS DEFINE CLUSTER, not JCL allocation. VSAM supports sequential access (in key order for KSDS, physical order for ESDS) and random access (by key, RBA, or RRN). So the main differences from sequential are: (1) random access capability, (2) different creation (IDCAMS), (3) DASD only, (4) no RECFM/BLKSIZE in the same sense—blocking is inside the CI.

VSAM vs Sequential: Comparison

VSAM vs sequential datasets
AspectVSAMSequential
AccessSequential and random (key, RBA, RRN)Sequential only (BSAM/QSAM)
CreationIDCAMS DEFINE CLUSTERJCL DD DISP=NEW, SPACE=...
StorageDASD onlyDASD or tape
Record formatInternal (CI); no RECFM in JCLRECFM, BLKSIZE, LRECL in DCB
CatalogAlways catalogedOptional CATLG

Creating a Sequential Dataset vs a VSAM Dataset

For a sequential dataset, a typical JCL step allocates the file with DISP=(NEW,CATLG), SPACE, and DCB. The program or a utility (e.g. IEBGENER) can then write records. For VSAM, you run a separate IDCAMS job with DEFINE CLUSTER; after that, your application JCL references the cluster by DSN and DISP=SHR or OLD. You never use DISP=(NEW,CATLG) with SPACE=... to create the VSAM dataset itself.

jcl
1
2
3
4
5
6
7
8
9
10
11
//ALLOCATE EXEC PGM=IEFBR14 //SEQFILE DD DSN=MY.SEQ.FILE,DISP=(NEW,CATLG), // SPACE=(TRK,(1,1)),UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000) // //DEFVSAM EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE CLUSTER (NAME(MY.VSAM.KSDS) INDEXED RECORDSIZE(80 80) - KEYS(10 0) VOLUMES(SYSDA) SPACE(1 1) TRACKS) /*

The first step allocates a sequential dataset with JCL. The second defines a VSAM KSDS with IDCAMS. Different tools, different syntax; sequential for the first, IDCAMS for the second.

When to Use Sequential

Use sequential when you only read or write the whole file in order: reports, logs, tape input/output, flat files for transfer. Use sequential when the dataset must be on tape or when you want to browse or edit with ISPF. Use sequential when you don’t need key or RBA access.

When to Use VSAM

Use VSAM when you need key-based or RBA-based access, when the same file is shared by batch and online, or when you need efficient inserts and deletes with space reuse. Use VSAM when the data must stay on DASD and the access pattern includes random lookups or updates.

Explain Like I'm Five

A sequential file is like a single long tape: you start at the beginning and read or write one thing after another. You can't jump to "the 50th record" unless you read through the first 49. VSAM is like a filing cabinet with labeled drawers: you can go straight to the drawer for "Smith" (key) or "drawer 5" (position), and you can also open drawer 1, then 2, then 3 if you want to read in order. So sequential = one direction, in order; VSAM = in order or jump to a key or position.

Test Your Knowledge

Test Your Knowledge

1. Which can reside on tape?

  • VSAM KSDS
  • Sequential (QSAM)
  • VSAM ESDS
  • LDS

2. How do you allocate a new sequential dataset?

  • IDCAMS DEFINE
  • JCL DD with DISP=NEW and SPACE
  • REPRO
  • LISTCAT
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