Defining a cluster proves you can talk to the catalog; loading proves you can move bits in the right order; reading proves the application world agrees with both. This page stitches those worlds together for a KSDS-shaped beginner path: verify with LISTCAT, load with sorted REPRO, open the dataset through JCL, and read from COBOL with explicit FILE STATUS handling. ESDS and RRDS variants are noted where they differ, but the spine matches what most training labs teach first because keyed files surface the richest lessons about ordering, positioning, and mistakes that look like “VSAM is broken” when the program never opened the right DSN.
| Step | What to verify |
|---|---|
| 1. Prove catalog health | LISTCAT the cluster; confirm SHAREOPTIONS, KEYS, and volumes match expectations. |
| 2. Load or refresh data | Sort keyed input ascending; REPRO into cluster; reconcile counts from SYSPRINT. |
| 3. Author JCL DD | DSN=cluster, DISP=SHR or OLD per concurrency; AMP only when tuning owners approve. |
| 4. Compile program with matching FD | RECORD CONTAINS / BLOCK CONTAINS align with VSAM RECORDSIZE; SELECT matches DD name. |
| 5. OPEN and check FILE STATUS | Treat non-00 statuses as hard stops until understood. |
| 6. Position then READ | Random: READ KEY; sequential: START optional then READ NEXT as pattern requires. |
| 7. CLOSE and report | Log record counts and abnormal statuses for operations. |
The DD name is the bridge between JCL and program. In COBOL, ASSIGN links the SELECT internal name to the DD name the binder expects. DISP=SHR allows shared read when policy permits; DISP=OLD signals exclusive use appropriate for some maintenance jobs. VSAM does not care about your program language—it honors allocation and sharing rules from the catalog and DD. Typos in DSN or DD omission produce FILE STATUS 35 at OPEN, not mysterious VSAM internals.
12345//READJOB EXEC PGM=COBTEST //STEPLIB DD DISP=SHR,DSN=DEPT.TRAIN.LOAD //CUSTMAS DD DISP=SHR,DSN=DEPT.TRAIN.CUST.KSDS //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=*
The sample uses fixed-area spacing so columns resemble traditional COBOL reference format: sequence area (1–6 blank), indicator (7 blank), Area A (8–11), Area B from column 12. Adjust names for your shop standards; compile with the same VSAM dataset definition you validated in LISTCAT.
123456789101112131415161718192021222324252627282930IDENTIFICATION DIVISION. PROGRAM-ID. COBTEST. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CUST-FILE ASSIGN TO CUSTMAS ORGANIZATION IS INDEXED ACCESS MODE IS SEQUENTIAL FILE STATUS IS WS-VSAM-STATUS. DATA DIVISION. FILE SECTION. FD CUST-FILE RECORD CONTAINS 80 CHARACTERS. 01 CUST-RECORD PIC X(80). WORKING-STORAGE SECTION. 01 WS-VSAM-STATUS PIC XX. PROCEDURE DIVISION. OPEN INPUT CUST-FILE IF WS-VSAM-STATUS NOT = '00' DISPLAY 'OPEN FAILED: ' WS-VSAM-STATUS STOP RUN END-IF READ CUST-FILE AT END DISPLAY 'NO FIRST RECORD' NOT AT END DISPLAY 'FIRST RECORD OK' END-READ CLOSE CUST-FILE STOP RUN.
Walk records in key order after optional positioning. Good for reports that sweep the file. For large files, design commit or checkpoint logic so restarts do not reread from scratch unintentionally.
Supply a key before each READ KEY. Useful for transaction lookups. Requires that the key buffer layout matches KEYS offset/length from DEFINE or you will read the wrong record or get NOT FOUND statuses.
Mix sequential and random operations in one session per language rules. Beginners should master SEQUENTIAL and RANDOM separately before relying on DYNAMIC nuances.
After the read job, compare program-record counts to control totals when available. If counts diverge, suspect duplicate keys absorbed during REPLACE loads, wrong KEY positions in the FD, or filters in START/READ pairs. Keep SYSPRINT from REPRO and the language listing together in the ticket so reviewers can correlate times and names.
Loading is pouring cereal into the box. Reading is opening the flap and taking one spoon at a time. If you yell into the pantry but never open the right box, you cannot taste cereal—that is forgetting the DD name bridge. If you pour before the box exists, cereal hits the floor—that is skipping DEFINE. The grown-up step is checking the label on the box twice: LISTCAT is the label photo.
1. A KSDS load completed with RC=0 but the file is empty at OPEN. Which check comes first?
2. FILE STATUS immediately after OPEN is 35. What class of problem is most likely?
3. For sequential KSDS reads, which statement often precedes the first READ NEXT in keyed browse-style loops?