VSAM File Status Codes — Ready-to-Use Copybook
Category: COBOL Programming
Overview
A comprehensive COBOL copybook for handling VSAM file status codes and error messages, ready to integrate into any COBOL program.
Core Structure
SELECT VSAM-FILE ASSIGN VSAMFILE
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
RECORD KEY IS VSAM-RECORD-KEY
FILE STATUS IS VSAM-STATUS-CODE
VSAM-EXTENDED-STATUS-CODE
Key Data Fields
- VSAM-STATUS-CODE: Two-byte field capturing primary status
- VSAM-EXTENDED-RETURN-CODE: Four-digit binary field (0, 4, 8, 12)
- VSAM-EXTENDED-FUNCTION-CODE: Indicates access type (base cluster, alternate index, or upgrade processing)
- VSAM-EXTENDED-FEEDBACK-CODE: Detailed diagnostic information
Primary Status Codes
| Code | Meaning |
| 00 | Successful completion |
| 02 | Duplicate key on non-unique alternate index |
| 04 | Read operation with incorrect record length |
| 10 | End of file |
| 20 | Invalid key on KSDS or RRDS |
| 23 | Record or file not found |
| 30 | Permanent data error (parity check, hardware) |
| 90-97 | Various VSAM-specific errors |
Logical Error Codes
| Code | Meaning |
| 004 | Read past end of file |
| 008 | Duplicate key attempt |
| 012 | Key sequence error |
| 016 | Record not found |
| 020 | Record held in exclusive control by another user |
| 040 | Insufficient virtual storage |
| 064 | All available strings exhausted |
| 092 | PUT without GET for update |
| 116 | Violated load mode restriction |