Relative files trade keys for numbers. Instead of searching a KSDS for employee 12345, you read relative record 12345 directly from a VSAM RRDS cluster—a grid of fixed slots where slot index is the address. Easytrieve declares them FILE TABFILE RELATIVE with optional UPDATE for slot maintenance. RRDS appears less often in introductory tutorials than KSDS, but operations teams use it for tables sized at allocation time, work queues indexed by slot, and legacy subsystems that predate modern DB2. This page explains RELATIVE FILE syntax, aligning slot count with IDCAMS MAXRRN, READ and WRITE by relative record number, empty slot handling with RESET, sequential GET across slots, and differences from INDEXED keyed access. Understand indexed files first; relative files reward the same discipline on DEFINE layout and JCL AMP.
123456FILE SLOTTAB RELATIVE UPDATE FB(40 1800) DEFINE SLOTTAB SLOT-RRN 9 1 * relative record number field SLOT-ACTIVE A 1 10 SLOT-DATA A 25 11
RELATIVE tells Easytrieve the access method addresses records by number. UPDATE permits rewriting slot contents. FB record length must match RRDS slot size from IDCAMS. MAXRRN in cluster define caps valid slot numbers; referencing beyond max produces errors. Some shops number slots starting at 1; verify whether your RRDS uses 1-based or 0-based convention in operations documentation.
| Organization | How you find data | Good fit |
|---|---|---|
| RRDS (RELATIVE) | Record number N | Fixed arrays, slot tables |
| KSDS (INDEXED) | Primary key value | Employee, account lookup |
| ESDS (SEQUENTIAL) | Next in entry order | Append-only logs |
Choose RELATIVE when application logic already computes an integer slot index. Choose INDEXED when operators search by business key. Mixing metaphors—storing employee ID as RRDN without contiguous numbering—wastes space and confuses maintainers.
Set the relative record number field to the slot you need, then issue READ file-name for retrieval or WRITE/PUT paths for update per Broadcom release documentation. STATUS captures FILE-STATUS when I/O fails—invalid slot, not defined, or authority. After READ, test whether SLOT-ACTIVE or equivalent flag shows the slot was ever written; empty slots may read as zeros when RESET zeros numeric fields on input.
12345678910COMPUTE SLOT-RRN = TABLE-INDEX + 1 READ SLOTTAB STATUS IF NOT SLOTTAB MOVE 'EMPTY' TO MSG EXIT END-IF IF SLOT-ACTIVE EQ 'N' MOVE 'UNUSED SLOT' TO MSG EXIT END-IF
RESET on FILE controls whether numeric fields zero when records load into buffers. Empty RRDS slots never written may return low-values or zeros; character fields may be blank or garbage if never initialized. Application designs include active flag, version stamp, or checksum in each slot so readers distinguish real data from never-used cells. Maintenance jobs preformat slots with active N before production load.
GET on RELATIVE files can walk slots in relative order—scan entire table for active entries without knowing keys in advance. JOB INPUT on RELATIVE with UPDATE supports batch walk-and-update similar to indexed browse. EOF marks end of allocated slot range. Combine GET scan with IF SLOT-ACTIVE to skip holes efficiently.
RRDS clusters define slot size and maximum records at IDCAMS time. DD allocation matches other VSAM types: DSN, DISP=SHR or OLD, AMP='AMORG=VSAM'. Growing RRDS may require redefinition offline—Easytrieve does not expand MAXRRN at runtime. Plan slot capacity with capacity management before coding RELATIVE FILE.
Slot update jobs READ or GET HOLD slot, MOVE new SLOT-DATA, WRITE back. DELETE in keyed sense may mean marking SLOT-ACTIVE N rather than physical remove—RRDS slots remain allocated. Batch refresh jobs zero slots then reload from sequential input using computed RRN from input record number field.
Broadcom documents RELATIVE for platform indexed relatives outside VSAM. FILE rules and verb availability follow the platform supplement. Mainframe RRDS remains the focus of this tutorial series; verify release notes when porting RELATIVE programs between environments.
A relative file is a row of numbered mailboxes. Mailbox 1, mailbox 2, up to the last number the building installed. You do not search by name—you say "open mailbox 17" and look inside. Empty mailboxes might look blank or full of zeros until someone puts real mail there. UPDATE means you may replace the mail in a mailbox that already exists. You cannot magically add mailbox 500 if the building only built 200 boxes—that is MAXRRN.
1. RELATIVE on FILE maps to VSAM:
2. Accessing slot 42 in RRDS uses:
3. Empty RRDS slots may return:
4. UPDATE on RELATIVE FILE allows:
5. RELATIVE differs from INDEXED because: