ORGANIZATION tells the COBOL run time which VSAM dataset shape you intend to mimic at the language level: indexed keyed files for KSDS, sequential entry order for ESDS, or relative slots for RRDS. ACCESS MODE narrows how your PROCEDURE DIVISION may move the file cursor: purely sequential walks, random jumps by key or RRN, or DYNAMIC mixtures. FILE STATUS is the two-character thermometer you read after each I/O verb to learn whether VSAM accepted the request, reached end of file, or rejected a key lookup. Together these three clauses explain most beginner mysteries that survive compile time and explode at OPEN or first READ. This page compares the organizations, contrasts access modes for KSDS workloads, and lists frequently encountered FILE STATUS values with practical interpretations while reminding you that exact text mapping belongs to your IBM Language Environment message manual for your release.
| COBOL ORGANIZATION | Typical VSAM target | ACCESS MODE notes |
|---|---|---|
| INDEXED | KSDS (and VSAM indexed clusters accessed as indexed files) | SEQUENTIAL, RANDOM, or DYNAMIC most common; keys drive RANDOM reads and START positioning. |
| SEQUENTIAL | ESDS and other sequential VSAM uses | Primarily SEQUENTIAL access; RANDOM may appear in specialized contexts—follow manual guidance. |
| RELATIVE | RRDS | RANDOM or SEQUENTIAL by relative record number using RELATIVE KEY. |
LDS and other specialized VSAM uses may not appear in classic COBOL FILE-CONTROL examples because applications access them through language extensions or assembler. Mainstream batch COBOL centers on KSDS, ESDS, and RRDS, which align with the three ORGANIZATION keywords above. If someone mentions LINEAR data sets in the same breath as COBOL, expect vendor interfaces or specialized runtimes rather than textbook FILE SECTION material.
ACCESS MODE must agree with what verbs you execute. Random READ without populating RECORD KEY first yields predictable confusion. Sequential READ after positioning with START requires understanding of how your shop uses START key comparisons. When in doubt, reproduce the smallest possible reproducer in a sandbox and step through with DISPLAY tracing before modifying production scheduling.
123456789101112131415161718192021FILE-CONTROL. SELECT CUSTFILE ASSIGN TO CUSTDD ORGANIZATION IS INDEXED ACCESS MODE IS RANDOM RECORD KEY IS CUST-KEY FILE STATUS IS WS-FS. WORKING-STORAGE SECTION. 01 WS-FS PIC XX. PROCEDURE DIVISION. OPEN INPUT CUSTFILE IF WS-FS NOT = '00' DISPLAY 'OPEN FS=' WS-FS STOP RUN END-IF MOVE '0000000123' TO CUST-KEY READ CUSTFILE IF WS-FS = '23' DISPLAY 'NOT FOUND' END-IF CLOSE CUSTFILE STOP RUN.
Treat DISPLAY tracing as temporary scaffolding; replace with structured logging where your platform supports it. The sample shows branching on 23 for not found style flows; confirm the exact code for your environment because installations can map VSAM conditions differently when VSAM returns extended status through file status versus VSAM feedback area in assembler programs.
| Code | Practical meaning |
|---|---|
| 00 | Successful completion of the last I/O or OPEN operation. |
| 10 | End of file on sequential READ; not an error for well-written loops. |
| 23 | Often “record not found” for keyed READ on KSDS; confirm in your Language Environment messages for exact wording. |
| 22 | Commonly duplicate key on WRITE when unique keys are required; verify against your manual. |
| 35 | Often OPEN failed because of mismatch or unavailable dataset; investigate JCL and catalog. |
| 92 | Often logic error such as WRITE without OPEN; treat as program bug after ruling out environmental causes. |
Advanced programs sometimes enable VSAM return code areas or use file handlers, but batch maintenance COBOL still lives mostly on FILE STATUS. When a status surprises you, copy the hex or character value into your incident ticket, pull the matching message ID from the LE guide, and cross-check LISTCAT for attribute mismatches. Many “random” VSAM bugs are actually OPEN parameter mismatches that manifest as odd status combinations on the first READ.
For RRDS, declare RELATIVE KEY IS data-name in FILE-CONTROL and move positive integers into that data item before each random READ or WRITE. Sequential processing still updates the relative key as VSAM advances through slots. Empty slots and deleted records have VSAM-specific semantics your design document must spell out so business analysts do not assume array-like compacting behavior that VSAM does not guarantee unless programmed explicitly.
ORGANIZATION is the rule book for how the closet of toys is sorted: by secret name tag, by arrival order, or by numbered basket slots. ACCESS MODE is how you are allowed to walk: only in line, only by jumping straight to a name tag, or both if the teacher says dynamic walking is okay today. FILE STATUS is the color light on your chest: green means the step worked, yellow means you reached the end of the line, red means the name tag you shouted is not on any toy.
1. Which ACCESS MODE lets a program mix sequential and random reads on the same OPEN?
2. FILE STATUS 10 after READ usually means:
3. RELATIVE KEY is required when: