VSAM Relative Byte Address (RBA)

The relative byte address (RBA) is the byte offset of a record (or the start of a control interval) from the beginning of the data component. In an Entry Sequenced Data Set (ESDS), there is no key—records are stored in write order. The only way to identify a specific record for direct access is by its position, and that position is expressed as the RBA: the number of bytes from the start of the file to the start of that record. When you read a record, you can obtain its RBA; if you save that value, you can later position back to the same record and read it again without scanning from the beginning. So RBA is the "address" of a record in an ESDS and is used for direct read, positioning, and resume-after-a-point. This page explains what an RBA is, how it is used in ESDS (and in KSDS where relevant), how it is assigned and when it changes, and how it compares to key and RRN.

What Is a Relative Byte Address?

The relative byte address is a number that gives the offset, in bytes, from the beginning of the data component to a specific point—usually the start of a record or the start of a control interval. The first byte of the data component is at RBA 0. If the first record starts at byte 0 and is 100 bytes long, the second record might start at RBA 100 (or at a slightly higher offset if there is control information between records). So RBA is "how many bytes from the start." It is typically stored as a 4-byte (32-bit) value, which limits the addressable range to about 4 GB per component unless extended addressability (e.g. XRBA or 64-bit RBA) is used. For most ESDS and KSDS datasets, 4-byte RBA is sufficient. The important idea is that RBA is position-based: it does not depend on the content of the record (like a key); it depends on where the record was placed when it was written.

How ESDS Uses RBA

An ESDS has no key and no index. The only ordering is entry sequence (write order). So to read a specific record you have two options: read sequentially from the beginning (or from some position) until you find it, or use the record's RBA. When you read a record from an ESDS, the access method can return the RBA of that record (the exact way depends on the programming interface—e.g. in COBOL you might get it from a special register or a parameter). You can store that RBA (e.g. in a variable, in a key, or in another file). Later, when you want to read that same record again, you issue a READ with that RBA (or a START at that RBA followed by a READ). VSAM then positions to that byte offset, reads the control interval that contains it, and returns the record. So RBA is the "direct access" mechanism for ESDS. It is also used to resume sequential processing: after reading 10,000 records, you save the RBA of the last record (or the next position); next time you open the file, you START at that RBA and READ NEXT to continue from where you left off. That way you do not have to reread the first 10,000 records.

When Is the RBA Assigned?

The RBA of a record is determined when the record is written. In an ESDS, when you append a record, VSAM places it at the current "end" of the file (at or after the high-used RBA). The byte offset where that record starts becomes its RBA. So the first record written has a small RBA (e.g. 0 or after a small amount of control data); the second has a larger RBA; and so on. Once the record is written, that RBA is fixed. It does not change when you open or close the file, or when you read other records. It can change only if the record is deleted (in which case the "record" and its RBA no longer exist in the same way) or if the entire file is reorganized (e.g. REPRO to a new cluster), which creates a new physical layout and new byte positions. So for a stable ESDS that is only appended to and not reorganized, every existing record keeps the same RBA for its lifetime. That stability is what allows you to save an RBA and use it later for direct read or resume.

Common Uses of RBA

Common uses of RBA in ESDS
Use caseDescription
Direct readYou saved the RBA when you first read the record; later you READ using that RBA to get the same record without scanning.
Resume sequential readYou save the RBA after reading N records; next run you START at that RBA and READ NEXT to continue where you left off.
Position for browseYou position to an RBA (e.g. start of a logical section) and then read sequentially from there.
Update in placeYou read a record (get its RBA), then REWRITE using the same RBA to update in place (if length does not increase beyond CI capacity).

In all of these, the RBA is the stable identifier for "where is this record" or "where should I start reading." Without a key, RBA is the only way to jump to a specific record or position in an ESDS.

RBA vs Key

In a KSDS, the primary way to find a record is by its key. The key is a field (or part of a field) in the record; VSAM uses the index to look up the key and get the data CI that contains the record, then returns the record. So key is "content-based" addressing: you identify the record by what it contains. RBA is "position-based": you identify the record by where it is. In an ESDS there is no key, so RBA (or sequential order) is the only option. In a KSDS you normally use key for random access; RBA is used internally (e.g. the index stores RBAs of data CIs) and may be exposed in the API for positioning (e.g. "start at this RBA and read sequentially") or for special purposes. So the main difference is: key = identify by content (key value); RBA = identify by position (byte offset). Key can change if you update the key field; RBA does not change unless the file is reorganized or the record is removed.

RBA vs RRN

RRN (Relative Record Number) is used in RRDS. It is a slot number (1, 2, 3, …), not a byte offset. So RRN says "the record in slot N"; RBA says "the record starting at byte M." In an ESDS you use RBA because there are no fixed slots—records are variable or fixed length and packed in entry order, so the only "address" is the byte offset. In an RRDS you use RRN because the dataset is a fixed set of slots and you address by slot number. So RBA is for ESDS (and KSDS for positioning); RRN is for RRDS. You do not use both on the same dataset; the dataset type determines which addressing method you have.

Primary addressing by VSAM type
TypePrimary addressingNotes
ESDSRBANo key; direct access and positioning by RBA. Sequential read in entry order.
KSDSKeyRandom access by key. RBA used internally (index) and may be exposed for positioning.
RRDSRRNDirect access by relative record number (slot). No RBA in the same sense.

RBA and Control Intervals

Physically, the data component is divided into control intervals. Each CI has a fixed size (e.g. 4096 bytes). The RBA of a record is the offset to the start of that record, which may be in the middle of a CI (after other records in the same CI). So when you give VSAM an RBA, it computes which CI contains that byte offset, reads that CI (if not already in a buffer), and then finds the record that starts at that RBA within the CI. You do not need to know the CI boundaries; you just use the RBA. The access method handles the mapping from RBA to CI and from RBA to record within the CI. So from the programmer's point of view, RBA is a simple "position in the file" value.

Stability and Reorganization

As long as you do not delete the record and do not reorganize the file (e.g. REPRO to a new cluster, or a utility that rewrites the file), the RBA of a record does not change. So RBAs are stable across opens and closes, and across runs of your program. If you store RBAs in a key or in another file (e.g. "bookmark" or "checkpoint"), they remain valid for that same ESDS. If you create a new version of the file (e.g. copy to a new cluster with different allocation or CI size), the physical layout of the new file is different and the old RBAs do not apply to the new file. So when you reorganize, you either stop using old RBAs or you rebuild your bookmarks from the new file (e.g. by scanning and saving new RBAs). For append-only ESDS with no reorganization, RBA stability is one of its strengths: once you have an RBA, you can use it indefinitely to reach that record.

Key Takeaways

  • RBA (Relative Byte Address) is the byte offset of a record from the start of the data component. It is position-based, not content-based.
  • In ESDS, RBA is the way to do direct access (read by RBA or position to RBA then read) because there is no key.
  • RBA is assigned when the record is written and is stable until the record is deleted or the file is reorganized.
  • RBA is used to resume sequential read (save RBA after N records; next time START at RBA and READ NEXT) and to reread a specific record.

Explain Like I'm Five

Imagine a long line of toy boxes. The first box is at "step 0," the next at "step 10," the next at "step 25," and so on. The "step number" is like the RBA: it tells you where to go to find that box. If you remember "the red car was at step 25," you can go straight to step 25 next time instead of walking from the start. The computer does the same with RBA: it remembers where each record is (how many bytes from the start) so you can jump straight to it.

Test Your Knowledge

Test Your Knowledge

1. What does RBA represent?

  • A key value
  • A byte offset from the start of the dataset
  • A record number
  • A control interval number

2. How do you access a specific record in an ESDS if you know its RBA?

  • Read by key
  • Read by RBA or position to RBA then read
  • Read by RRN
  • You cannot; ESDS is sequential only

3. When can the RBA of a record change?

  • On every read
  • When the record is updated
  • When the file is reorganized or the record is deleted
  • Never
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