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 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 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.
| Aspect | VSAM | Sequential |
|---|---|---|
| Access | Sequential and random (key, RBA, RRN) | Sequential only (BSAM/QSAM) |
| Creation | IDCAMS DEFINE CLUSTER | JCL DD DISP=NEW, SPACE=... |
| Storage | DASD only | DASD or tape |
| Record format | Internal (CI); no RECFM in JCL | RECFM, BLKSIZE, LRECL in DCB |
| Catalog | Always cataloged | Optional CATLG |
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.
1234567891011//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.
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.
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.
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.
1. Which can reside on tape?
2. How do you allocate a new sequential dataset?