Easytrieve Relative File Processing

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.

Progress0 of 0 lessons

FILE RELATIVE Declaration

text
1
2
3
4
5
6
FILE 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.

RRDS Versus KSDS Versus ESDS

When relative beats keyed or sequential
OrganizationHow you find dataGood fit
RRDS (RELATIVE)Record number NFixed arrays, slot tables
KSDS (INDEXED)Primary key valueEmployee, account lookup
ESDS (SEQUENTIAL)Next in entry orderAppend-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.

Reading and Writing Slots

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.

text
1
2
3
4
5
6
7
8
9
10
COMPUTE 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 and Empty Slots

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.

Sequential Browse With GET

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.

JCL and Allocation

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.

UPDATE Maintenance Patterns

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.

Relative Files on Non-z/OS Platforms

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.

Common Relative Mistakes

  • RRN outside 1..MAXRRN range.
  • Treating uninitialized slot as valid business data.
  • Using INDEXED READ against RRDS DD.
  • Slot size mismatch between FILE FB and IDCAMS.
  • UPDATE missing on slot rewrite job.
  • Confusing relative record number with KSDS key value.

Explain It Like I'm Five

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.

Exercises

  1. Declare RELATIVE FILE with active flag and data fields.
  2. Write logic that READs one slot by computed RRN and handles empty active flag.
  3. Compare RRDS versus KSDS for a 10,000-row table keyed by contiguous IDs.
  4. List JCL and IDCAMS items to verify before first RRDS test run.
  5. Sketch GET loop that scans all slots and PRINT only active ones.

Quiz

Test Your Knowledge

1. RELATIVE on FILE maps to VSAM:

  • RRDS
  • KSDS only
  • ESDS only
  • Tape U format

2. Accessing slot 42 in RRDS uses:

  • Relative record number in file verbs
  • SQL FETCH
  • Printer LINE only
  • JCL only

3. Empty RRDS slots may return:

  • Zeros or low-values when RESET applies
  • Always duplicate key
  • SQL null only
  • JCL error

4. UPDATE on RELATIVE FILE allows:

  • Writing into existing numbered slots when permitted
  • Only SYSPRINT
  • Bypassing DEFINE
  • DLI PCB

5. RELATIVE differs from INDEXED because:

  • Address by record number not primary key field
  • Only sequential tape
  • No FILE statement
  • Only online screens
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 RELATIVE FILE RRDSSources: Broadcom Easytrieve 11.6 Language Reference RELATIVE, VSAM RRDSApplies to: Easytrieve VSAM RRDS relative processing