VSAMintermediate

VSAM File Status Codes and Error Handling

Recognize the most common VSAM FILE STATUS codes returned to COBOL programs and understand the disciplined error-handling patterns built around them.

Every VSAM I/O operation in a COBOL program returns a two-character FILE STATUS code indicating exactly what happened, and fluency with the common codes is one of the most practical, frequently tested pieces of mainframe knowledge because nearly every production VSAM incident investigation starts with 'what file status did we get?' Interviewers expect you to recognize the handful of codes that come up constantly, not memorize the entire exhaustive list.

A VSAM file status code is the receipt printed after every ATM transaction — most of the time it just confirms success, but a specific code for 'insufficient funds' versus 'card not recognized' versus 'network error' tells you precisely what actually happened and what to do next, and a careful person reads that receipt every single time rather than assuming the transaction always went through.

Key Concepts

1
'00' means successful completion — the baseline everything else is compared against. '10' signals end-of-file on a sequential read, the normal, expected way a read loop terminates rather than an error condition. '23' means the requested record was not found (on a random read) or, in some contexts, a duplicate key was detected on a write — precisely the kind of code whose correct handling depends heavily on context, which is exactly why interviewers like asking about it. '22' indicates a duplicate key error on an attempted WRITE where uniqueness is required, and '92' typically reflects a logic error, such as attempting an operation the file's current OPEN mode doesn't support.
2
Good COBOL practice checks FILE STATUS immediately after every READ, WRITE, REWRITE, and DELETE against a VSAM file, branching to appropriate handling logic rather than assuming success — this mirrors the same discipline DB2 programs apply to SQLCODE, and interviewers often draw that parallel explicitly to see if a candidate recognizes the pattern repeats across different mainframe subsystems.
3
A well-prepared answer distinguishes status codes that represent normal, expected outcomes (like '10' for end-of-file) from those representing genuine problems requiring active handling or escalation (like '35' — file not found at OPEN time, or '37' — an OPEN mode conflict), and explains that a program should never silently ignore a non-zero, non-expected status code, since doing so is one of the most common root causes of silent data corruption in legacy VSAM applications.