Mainframe Path Start learning free
BeginnerError and abend codesFS 35/39/22/23/92

COBOL file status 35, 39, 22, 23, 92 — VSAM I/O errors

The two-character FILE STATUS tells you why an OPEN, READ or WRITE on a VSAM file failed. Learn the handful that cover most incidents.

What happened

A COBOL program working with a VSAM file got a non-zero file status on an OPEN, READ, WRITE, REWRITE or DELETE. Depending on how the program is written it either displays the status and ends with a return code or user abend, or it carries on and fails later.

Program display after a failed OPEN (illustrative)Illustrative example
MPACCT01 OPEN FAILED  FILE=ACCTMAST  STATUS=39
MPACCT01 VSAM RC=0008 FUNC=0000 FDBK=0000
MPACCT01 ENDING WITH RETURN CODE 16

What it means

The first digit gives the class (0 success, 1 at end, 2 invalid key, 3 permanent error, 4 logic error, 9 implementor-defined). The codes you meet most with VSAM:

StatusMeaning
00 / 02 / 97Success. 02 = duplicate alternate key that is allowed. 97 = OPEN succeeded after VSAM verified the file's integrity.
10End of file on a sequential READ.
21Sequence error — key changed between READ and REWRITE, or keys written out of ascending order.
22Duplicate key on WRITE or REWRITE where duplicates are not allowed.
23Record not found on a random READ, START or DELETE.
35OPEN INPUT, I-O or EXTEND of a required file that is not available (often no DD or no dataset).
37OPEN mode not allowed for this file.
39OPEN found a conflict between the file's fixed attributes and the program's (organization, key, record size).
41 / 42 / 47 / 48 / 49Logic errors: already open, not open, or wrong open mode for READ, WRITE, DELETE/REWRITE.
92Logic error (general).
93Resource not available — another job or region holds the dataset.
96No DD statement for a file that needs one.

For VSAM files, the FILE STATUS clause can name a second, 6-byte data item. It holds the VSAM return code (0, 8 or 12), function code (0–5) and feedback code (0–255) as three 2-byte binary fields. They are set only when VSAM returns a non-zero return code, and are meaningful only then.

Typical causes

Symptoms

Where to look

How to diagnose

  1. Note the status and the operation (OPEN, READ, WRITE…) and, for VSAM, the extended codes.
  2. For 35/96 check the DD name in JCL against the ASSIGN name in the program.
  3. For 39 compare LISTCAT KEYS and RECORDSIZE with the record layout and key definition in the program.
  4. For 22/23 capture the key value and check the input data or the key-building logic.
  5. For 93 find who else holds the dataset at that time.

How to fix

Fix the cause, not the symptom: add or correct the DD, redefine the cluster to the agreed attributes with IDCAMS, correct the FD to match the cluster, or clean the duplicate keys in the input. Then restart from the agreed point — for loads that already wrote records, check whether a rerun will cause 22s and agree a recovery plan first.

How to prevent

Production considerations

Interview question

A batch program gets file status 39 on OPEN of a KSDS. What do you check?

Stuck on something else?
Ask the community or search the full course.

Ask a question