To read, update, or delete a specific record in a VSAM dataset, the system must know how to find it. That is addressability: the way you identify and position to a record. VSAM uses different methods depending on the dataset type. Key Sequenced Data Sets (KSDS) use the primary key. Entry Sequenced Data Sets (ESDS) use the relative byte address (RBA). Relative Record Data Sets (RRDS) use the relative record number (RRN). Linear Data Sets (LDS) are addressed by byte offset. This page explains each form of addressability, when it is used, and how it affects how you write your programs. It also briefly covers extended addressability (e.g. XRBA) for datasets larger than 4GB.
When your program issues a READ (or START followed by READ NEXT), it must tell the access method which record it wants. In a sequential file you might just read next; in a VSAM file you often want a specific record. The way you specify that record is the addressability. For KSDS you supply the key (or a key range for START). For ESDS you might supply an RBA to position to a specific record. For RRDS you supply the RRN (slot number). The access method then uses that information to find the right control interval (CI), read it into a buffer if needed, and return (or update) the record. So addressability is the link between your program's request and the physical location of the data on disk.
| Type | Method | Description |
|---|---|---|
| KSDS | Key | Primary key (offset + length in record); READ key or START key then READ NEXT |
| ESDS | RBA | Relative byte address (4 bytes); position or read by byte offset from start of dataset |
| RRDS | RRN | Relative record number (slot number 1, 2, 3, …); fixed-length slots |
| LDS | Byte offset | No records; access by byte offset into the linear byte stream |
In a KSDS, each record has a primary key. The key is defined at DEFINE CLUSTER time with KEYS(length offset)—for example KEYS(10 0) for a 10-byte key at offset 0. The key must be unique (or you can allow duplicates with NONUNIQUEKEY in some cases). To read a record, you typically issue a READ with the key. The access method uses the index component to find which control interval contains that key, reads that CI, and returns the record. You can also issue START key to position at a key (or the first record with a key greater than or equal to a value), then READ NEXT (or READ PREV) for sequential processing from that point. So key-based addressability is the main way you get random and skip-sequential access in a KSDS.
In an ESDS there is no key. Records are stored in the order they were written (entry order). Each record (or each CI) has a position in the dataset expressed as a byte offset from the beginning. That offset is the relative byte address (RBA). RBA is typically a 4-byte value. You can read a record by RBA: you position to that RBA (e.g. with a START or POINT) and then read. You can also read sequentially and the access method will return the RBA of each record so you can use it later for direct access. RBA is stable: once a record is written, its RBA does not change unless the dataset is reorganized. So RBA addressability is ideal when you need to remember "where" a record is and come back to it later (e.g. for an ESDS used as a log or audit trail).
In an RRDS the dataset is divided into fixed-length slots. Each slot has a number: 1, 2, 3, and so on. That number is the relative record number (RRN). To read or write a specific record you specify the RRN. The access method computes which control interval contains that slot and accesses it. Slots can be empty (after a delete) or full. So RRN addressability is like an array: you address by slot index. It is useful when you have a fixed set of "buckets" (e.g. one record per customer ID if the ID maps to a slot number) or when you need direct access by position rather than by key.
A Linear Data Set (LDS) has no record structure. It is a contiguous stream of bytes. Addressability is by byte offset from the start of the dataset. Programs (or products like DB2) that use an LDS manage their own structures on top of the bytes; VSAM just delivers the bytes at the requested offset. So LDS addressability is at the byte level, not the record level.
Standard RBA is 4 bytes, which limits the addressable size of a dataset to 4GB. For larger VSAM datasets, z/OS supports extended addressability. The extended relative byte address (XRBA) is an 8-byte value that can address datasets larger than 4GB. Applications that need to position or read beyond 4GB must use the XRBA interface (e.g. in CICS or in language-specific APIs) instead of the 4-byte RBA. The standard RBA field may return a special value (e.g. -1 or high values) when the record is beyond 4GB to indicate that XRBA must be used. So for very large ESDS (or for KSDS/RRDS with large byte offsets), addressability extends to XRBA.
When you give a key, RBA, or RRN, the access method translates it into a specific control interval. For KSDS it uses the index to find the CI that contains the key. For ESDS it divides the RBA by the CI size (or uses a similar mapping) to get the CI. For RRDS it computes the slot position and maps that to a CI. Once the CI is identified, the access method checks whether that CI is already in a buffer; if not, it reads the CI from the data component. Then it locates the record within the CI (by key match, RBA, or slot) and returns it to your program (or updates it). So addressability is the input; the output is the correct record (or a condition like "not found").
Imagine finding a page in a book. For a KSDS, you use the index: you look up the topic (the key) and the index tells you the page (the CI). For an ESDS, you count how many pages from the start the page is (that's the RBA). For an RRDS, every page has a number (1, 2, 3…) and you say "give me page 5" (that's the RRN). VSAM addressability is the rule for how you say "which record do you want?" so the system can find it.
1. Which VSAM type uses RBA for record positioning?
2. What does RRN stand for in VSAM?
3. How does a program find a record in a KSDS?