VSAM Variable RRDS (VRRDS)

A variable RRDS (VRRDS) is a Relative Record Data Set in which records can have different lengths. You define it with NUMBERED and RECORDSIZE(average maximum) where the average and maximum are not the same—for example RECORDSIZE(50 200). Unlike a fixed RRDS, there are no fixed-size slots on disk; instead, an INDEX component maps each relative record number (RRN) to the physical location of the record. You still access records by RRN (direct addressing), but the system uses the index to find each record. This page explains what VRRDS is, how it differs from fixed RRDS, how to define it with DEFINE CLUSTER (including the INDEX component and VOLUMES), and when to choose VRRDS over fixed RRDS or other VSAM types.

What Is a Variable RRDS (VRRDS)?

In a fixed RRDS every record has the same length and the file is divided into fixed slots. In a variable RRDS records can vary in length within a range you specify (e.g. 50 to 200 bytes). So one record might be 80 bytes and the next 120 bytes. Because lengths vary, the system cannot compute "slot N" as a simple offset. Instead, VRRDS uses an index component—similar in concept to a KSDS index—that maps each RRN to the location of that record. When you set the RRN and issue READ, the access method looks up the RRN in the index and uses the stored pointer to read the record. So you still get direct access by RRN, but the mechanism is index-based rather than slot-offset-based.

Why VRRDS Needs an Index

In a fixed RRDS the position of record (slot) N can be calculated: N × record-length (plus control information). In a variable RRDS record lengths differ, so there is no fixed slot size. The only way to find "record with RRN 5" is to maintain a mapping: RRN 5 → location. That mapping is the index. The index is ordered by RRN and holds, for each RRN, the information needed to locate the record in the data component. So VRRDS has both a data component (where variable-length records are stored) and an index component (which maps RRN to record). When you insert, delete, or replace records, the index is updated to reflect the new locations or the removal of the RRN.

RECORDSIZE: Average and Maximum

For VRRDS you specify RECORDSIZE(average maximum) with two different values. The average is used for space estimation and possibly for buffer sizing; the maximum is the largest record length allowed. For example RECORDSIZE(80 120) means records can be from 1 to 120 bytes (or whatever the minimum is for your system), with an average of 80. Every record you write must not exceed the maximum. If you use the same value for both (e.g. RECORDSIZE(80 80)), you have a fixed RRDS, not a VRRDS, and you do not define an index.

DEFINE CLUSTER for Variable RRDS

You create a VRRDS with DEFINE CLUSTER by specifying NUMBERED, RECORDSIZE(avg max) with avg and max different, and both DATA and INDEX components. Allocate space for both components. On many systems VOLUMES should be specified at the cluster level so that both the data and index components receive volume allocation; if VOLUMES is only on DATA, the define may fail because the index has no volume. The following example shows the structure.

Key DEFINE CLUSTER parameters for VRRDS
ParameterDescription
NUMBEREDSpecifies RRDS (required for both fixed and variable RRDS).
RECORDSIZE(avg max)For VRRDS, average and maximum differ (e.g. 50 200). Records can be any length from min up to max.
INDEX componentRequired for VRRDS. Maps RRN to record location; no fixed slots.
DATA and INDEXBoth components must be defined; each can have its own space allocation.
VOLUMESOften specified at cluster level so both DATA and INDEX get volume allocation.

Example: Defining a Variable RRDS

jcl
1
2
3
4
5
6
7
8
9
10
11
DEFINE CLUSTER ( - NAME(USERID.MY.VRRDS) - NUMBERED - RECORDSIZE(80 200) - CYLINDERS(5 2) - VOLUMES(volser) - REUSE) - DATA (NAME(USERID.MY.VRRDS.DATA) - CYLINDERS(4 1)) - INDEX (NAME(USERID.MY.VRRDS.INDEX) - CYLINDERS(1 1))

NUMBERED makes it an RRDS. RECORDSIZE(80 200) allows variable-length records with average 80 and maximum 200 bytes. VOLUMES at the cluster level applies to both components. DATA and INDEX each have their own space (CYLINDERS). REUSE, if supported for VRRDS on your system, allows a deleted RRN to be reused for a new record. The index will map each RRN to the corresponding record in the data component.

Fixed RRDS vs Variable RRDS

Fixed RRDS has same-length records and no index; RRN is the slot number and the slot position is computed. Variable RRDS has variable-length records and an index; RRN is the logical record number and the index maps it to the record. Fixed RRDS is simpler and uses less metadata (no index); VRRDS is more flexible for varying record sizes but requires index maintenance and more space for the index. Choose fixed RRDS when all records are the same length; choose VRRDS when record lengths vary.

Fixed RRDS vs variable RRDS (VRRDS)
AspectFixed RRDSVariable RRDS (VRRDS)
Record lengthAll records same lengthRecords can vary within min–max range
RECORDSIZERECORDSIZE(n n)RECORDSIZE(avg max), avg < max
IndexNo indexINDEX component required
RRN mappingRRN = slot position (computed)Index maps RRN to record

Operations on VRRDS

You can READ by RRN (the index finds the record), WRITE at an RRN (insert or assign that RRN; the index is updated), REWRITE after READ (update in place; record length can change within the max), and DELETE at an RRN (remove the record and free the RRN; with REUSE the RRN can be reused). Sequential access reads records in RRN order (1, 2, 3, …); the index is used to traverse in RRN order. Direct access is by RRN as in fixed RRDS, but each access goes through the index to locate the record.

RRN in VRRDS

The RRN in VRRDS is still the relative record number: 1 for the first record, 2 for the second, and so on. The difference is that in fixed RRDS the RRN is tied to a fixed slot, while in VRRDS the RRN is a logical number maintained by the index. When you delete a record in VRRDS, that RRN can be reused for a new record if the cluster has REUSE. So the RRN space can be recycled. The index keeps the mapping from RRN to current record location; when you insert a new record at a reused RRN, the index is updated to point to the new record.

When to Use VRRDS

Use VRRDS when you need RRN-based (position-based) access but your records have different lengths. For example, a table where each "row" is identified by row number (RRN) but the row content length varies. Use fixed RRDS when all records are the same length—it is simpler and has no index overhead. Use KSDS when you need key-based access rather than position-based. Use ESDS when you need append-only with stable RBA addresses.

Key Takeaways

  • Variable RRDS (VRRDS) allows records of different lengths; specify RECORDSIZE(avg max) with avg and max different.
  • VRRDS requires an INDEX component that maps RRN to record location; there are no fixed slots.
  • Define both DATA and INDEX; VOLUMES at cluster level often needed for both components.
  • Access is still by RRN (direct or sequential); the index is used to find each record.
  • Use VRRDS when record lengths vary; use fixed RRDS when all records are the same length.

Explain Like I'm Five

Imagine a row of cubbyholes where each cubbyhole can be a different size. You still number them 1, 2, 3, 4, 5. But because they're different sizes, you need a list (the index) that says "number 1 is here, number 2 is there." When you ask for the thing in cubbyhole 3, you check the list to find where 3 is, then go there. That list is the index. Fixed RRDS is when every cubbyhole is the same size so you don't need the list—you just count over. Variable RRDS is when they're different sizes so you need the list.

Test Your Knowledge

Test Your Knowledge

1. What distinguishes VRRDS from fixed RRDS in RECORDSIZE?

  • VRRDS uses RECORDSIZE(n n)
  • VRRDS uses RECORDSIZE(avg max) with avg < max
  • VRRDS has no RECORDSIZE
  • VRRDS uses RECORDSIZE(0 max)

2. Why does VRRDS require an INDEX component?

  • To store keys
  • To map RRN to record location (no fixed slots)
  • To support sequential access only
  • To allow REUSE

3. In VRRDS, how is a record found when you READ by RRN?

  • By computing slot offset
  • By searching the data sequentially
  • By looking up RRN in the index
  • By key search
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