A VSAM file that has never contained a record is treated as unavailable. Attempting to open for input will fail. An empty file can be opened for output only. When you open for output, COBOL will write a dummy record to the file & then delete it out.
VSAM distinguishes between an empty data set (that is, one that has never had a record in it) and a data set with no records (for example, adding a record to a KSDS and then deleting it). The difference is that for each write to a VSAM data set, a pointer is updated to reflect the highest used RBA. If you have never written any data to the data set, this pointer has no value and hence causes VSAM problems when attempting to use it to locate the end of the used data. Any program attempting to open a VSAM data set for input before anything has been written to the data set will have a problem & amend will happen with return code 35 as VSAM is unavailable.
Example
//STEP010 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSIN DD * DELETE XXXXX.TEST.VSAM PURGE CLUSTER DEFINE CLUSTER(NAME(XXXXX.TEST.VSAM) - VOLUME(* *) - UNIQUE - SHAREOPTIONS(3 3) - CYLINDERS(7 7)) - DATA (NAME(XXXXX.TEST.VSAM.DATA) - KEYS (29 0) - RECORDSIZE(35 35) - CISZ(4096)) - INDEX (NAME(XXXXX.TEST.VSAM.INDEX) - NOIMBED NOREPLICATE) /* //STEP020 EXEC PGM=IDCAMS //IN DD DSN=XXXXX.TEST.PS,DISP=SHR //OUT DD DSN=XXXXX.TEST.VSAM,DISP=SHR //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSIN DD * REPRO INFILE(INF) OUTFILE(OUTF) COUNT(1) /*
| Code | Typical meaning | Common causes | Recommended action |
|---|---|---|---|
| 00 | Successful completion | Normal I/O | Continue processing |
| 02 | Non-unique alternate key condition | AIX non-unique read condition | Validate access path and logic |
| 04 | Length mismatch / boundary-related record issue | LRECL mismatch, variable-length inconsistency | Check layout, copybook, and record format |
| 10 | End of file / no more records | Sequential browse complete | End loop cleanly |
| 14 | RRDS relative record out of range | Invalid RRN or slot | Validate record number and file size |
| 20 | Invalid key / sequence issue | Bad key value, wrong sequence | Check key definition and access mode |
| 21 | Duplicate or sequence error | Insert to existing key, bad REWRITE key change | Handle as business duplicate or fix key logic |
| 22 | Duplicate primary key | KSDS duplicate insert | Route to duplicate handling process |
| 23 | Record not found / permanent read issue | Search miss, incorrect key, deleted data | Recheck key, indexing, and data load integrity |
| 24 | Key outside boundary | High/low key violation | Validate key range and start position |
| 28 | Space issue | CI/CA exhaustion, file full | Reorganize or extend cluster |
| 30 | Permanent I/O error | Device, dataset, or media issues | Escalate to storage/operations; inspect logs |
| 34 | Boundary violation | Relative or sequential boundary issue | Verify access mode and record position |
| 35 | Open failure / file not present / definition issue | Missing DD, wrong DISP, missing catalog entry | Check JCL and file definition |
| 37 | Wrong open mode | INPUT vs I-O vs OUTPUT mismatch | Correct COBOL OPEN mode |
| 38 | File locked | Share or enqueue conflict | Review sharing, batch overlap, and CICS serialization |
| 39 | Conflicting file attributes | DD/COPYBOOK mismatch, wrong organization | Align program and data set definition |
| 41 | File already open | Logic error | Prevent double open in run unit |
| 42 | Close on non-open file | Logic error | Guard CLOSE with state checks |
| 43 | REWRITE without prior READ for update | Program sequence error | Ensure successful READ before REWRITE |
| 44 | Length mismatch on REWRITE | Record length changed unexpectedly | Preserve original record format |
| 46 | Read beyond EOF / no current record | Bad sequential flow | Check 10 and EOF condition logic |
| 47 | READ on file not open for input/I-O | Wrong mode or control flow | Open correctly before READ |
| 48 | WRITE on file not open for output/I-O | Wrong mode | Correct OPEN mode |
| 49 | DELETE/REWRITE on file not open I-O | Wrong mode | Ensure I-O access before update verbs |
| 90 | Unsuccessful I/O operation | Generic failure | Use VSAM detail and job logs |
| 91 | Authorization failure | Security / access control | Verify authority |
| 92 | Logic error | Program sequencing | Add state validation and unit tests |
| 93 | Resources unavailable | Buffer, latch, or sharing issue | Review resource contention and environment |
| 94 | Sequential record unavailable / concurrent open error | Sharing conflict | Check serialization and access rules |
| 95 | Invalid or incomplete file info | Bad attributes or missing definitions | Verify DD and file definition |
| 96 | No DD statement | JCL allocation missing | Add or fix DD statement |
| 97 | Open successful and integrity verified | Successful open with verification | Continue processing |
| 98 | File locked | Dataset lock / allocation issue | Clear contention or wait/retry |
| 99 | Record locked | Locked record access failed | Retry under proper lock strategy |
VSAM return code 00 – SUCCESSFUL COMPLETION
Root Cause:
Fix:
VSAM return code 04 – READ, WRONG LENGTH RECORD
Root Cause: The logical error in the program
Fix: The Logic of the COBOL Program itself is wrong so you need to correct the logic of the program.
VSAM return code 13 – File Not Found
Root Cause: File Not Found
Fix: Provide the correct details of the file name. Check if the path of your VSAM file is correct.
VSAM return code 16 – Accessing VSAM file Error
Root Cause: It depends on the type of file, the program used to access the VSAM file and is mostly related to accessing
Fix: Fix will be based on the way you are accessing the file from a program. Are you trying to update a file for which you do not have permission?
VSAM return code 19 – Accessing VSAM file Error
Root Cause: In case you are accessing the VSAM file in CICS and you did not provide a proper entry of the file
Fix: Check if the PCT entry of the file is proper.
VSAM return code 20 – INVALID KEY VSAM KSDS OR RRDS
Root Cause: In the case of KSDS or RRDS, the key is an INVALID KEY
Fix: Correct the KEY. Check the position, definition, etc and correct it.
VSAM return code 22 – DUPLICATE KEY
Root Cause: Duplicate key defined for Indexed or relative Files. Duplicate alternate key but the alternate key is defined as unique.
Fix: Remove the duplicate entry of the key.
VSAM return code 23 – RECORD NOT FOUND or FILE NOT FOUND
Root Cause: The record is not found when you are trying to access using a key. File not found.
Fix: Check if the record is correct or the path to access the file is given correctly.
VSAM return code 24 – Invalid Key – key outside the boundary of file.
Root Cause: Trying to write beyond the boundary in case of Relative and indexed files using the key. The size of the Relative Record number is larger.
Fix: Do not write beyond the boundary or change the boundary.
VSAM return code 28 – Unable to extend the dataset
Root Cause:
Fix: Check with your storage group or try to give less value to your secondary allocation.
VSAM return code 35 – OPEN, FILE NOT PRESENT
Root Cause: You are trying to open a file that is not present.
Fix:
VSAM return code 37 – Open file error due to opening mode
Root Cause: You are trying to open a file in a particular mode that is not allowed for that file.
Fix: Check the file opening modes available for the file and fix it.
VSAM return code 39 – LOGIC ERROR
Root Cause:
Fix: Check the file attribute in the actual file, the file attributes defined in the FD section of the program, the record length in your DCB Parameter and the record mode, etc.
VSAM return code 41 – OPENING A FILE THAT IS ALREADY OPENED
Root Cause: You are trying to open a file in a particular mode that is not allowed for that file.
Fix: Check the file opening modes available for the file and fix it.
VSAM return code 42 – CLOSING A FILE WITHOUT OPEN.
Root Cause: When the file is already closed and you try to do a CLOSE operation once again on the file which is already closed.
Fix: Change the program to make sure that you do not give a CLOSE file on the file which is already closed.
VSAM return code 46 – SEQUENTIAL READ WITHOUT POSITIONING
Root Cause: If you try to sequentially read a file even when the end of the record is reached.
Fix: Once the End of the File is reached, do not read the file.
VSAM return code 47 – READING FILE NOT OPEN AS INPUT/IO/EXTEND
Root Cause: File not opened in INPUT or I-O mode.
Fix: Open the file in INPUT or I-O mode.
VSAM return code 90 – Unsuccessful OPEN, READ, WRITE or CLOSE operation
Root Cause:
Fix:
VSAM return code 91 – Password or authorization failed
Root Cause: Password Failure. Authorization failure.
Fix: Check the password which is given for VSAM file or whether you are authorized to access the file or not?
VSAM return code 92 – LOGIC ERROR / OPENING A OPEN FILE / READING OUTPUT FILE / WRITING INTO A INPUT FILE / DEL or REW BUT NO PRIOR READ
Root Cause:
Fix:
VSAM return code 93 – OPENING A FILE THAT IS ALREADY OPENED
Root Cause:
Fix: Check with your storage group.
VSAM return code 96 – MISSING DD STATEMENT IN JCL
Root Cause: Missing DD statement for the VSAM or QSAM file.
Fix: Code the missing DD statement in the JCL
VSAM return code 97 – OPEN OK, FILE INTEGRITY VERIFIED
Root Cause: OPEN file successful and the file integrity verified. This might happen when a previous Job did not close the file so VSAM has to verify the integrity of the file.
Fix: Check the file opening modes available for the file and fix it.
VSAM return code 100 – Improper loading
Root Cause:
Fix: Before building the alternate index(AIX) and path, you need to load the cluster.
VSAM return code 160 – input file might be empty
Root Cause: The input file might be empty when you try to open it.
Fix: Check with your storage group.
VSAM return code 168 – The device type is not supported
Root Cause: The device type is not supported.
Fix: Check with your admin.
| Symptom | Likely cause | First check | Next step |
|---|---|---|---|
| OPEN returns 35 | Missing DD, wrong DISP, catalog issue | JCL and LISTCAT | Fix allocation or catalog entry |
| READ returns 10 | EOF reached | Sequential loop logic | Exit loop cleanly |
| WRITE returns 22 | Duplicate key | Business rule or source data | Quarantine duplicate and continue or reject |
| REWRITE returns 43 | No prior READ for update | Program flow | Ensure positioned record exists |
| DELETE returns 49 | Not opened I-O | OPEN mode | Switch to I-O |
| 90/93/95 class code | Environmental or resource issue | VSAM detail + job log | Resolve security, resource, or definition issue |
Use this decision path for rapid triage:
Did the failure occur at OPEN? If yes, inspect JCL, DD allocation, catalog entry, and data set attributes.
Did it occur on READ/WRITE/REWRITE/DELETE? If yes, confirm OPEN mode, file organization, and verb sequencing.
Is the status in the 20s? If yes, inspect key logic, duplicate handling, and file positioning.
Is the status in the 30s or 90s? If yes, inspect the environment, security, locks, resources, and definition integrity.
Is the file interrupted after an abend? If yes, run VERIFY ... RECOVER and then EXAMINE.
Case 1: Duplicate insert in KSDS. A nightly load received status 22 because the upstream system resent a customer number already present in the cluster. The team changed the load to separate new inserts from correction updates and routed duplicates to a reject file.
Case 2: Open failure after deployment. A new COBOL package returned status 35 because the DD statement was missing in the promoted JCL stream. The fix was to align the deployment checklist with catalog validation and automated LISTCAT verification.
Case 3: Interrupted update after abend. A KSDS was left in an uncertain state after a CANCEL. Operations ran VERIFY DATASET(... ) RECOVER, then EXAMINE to confirm health before resuming REPRO processing.
Not checking FILE STATUS after every verb.
Using the wrong OPEN mode for the intended operation.
Ignoring duplicate-key handling in KSDS loads.
Assuming 35 is always a data problem instead of a JCL or catalog issue.
Rewriting without confirming prior READ for update.
Missing or stale PATH/AIX definitions after base-cluster changes.
Reloading data without structural validation.
Overbuffering without measuring paging impact.
Mixing batch and CICS assumptions about locking and sharing.
Treating VSAM Initialization as a one-time task instead of a lifecycle process.
Q1. What is the difference between COBOL file status and VSAM status?
COBOL file status is the high-level two-byte result code, while the VSAM status area provides more detailed return information for VSAM files.
Q2. When should you use EXAMINE and VERIFY?
Use them after interrupted VSAM processing or when structural integrity is in doubt; VERIFY ... RECOVER followed by EXAMINE is a common recovery pattern.
Q3. What is the main difference among KSDS, ESDS, and RRDS?
KSDS is key-based, ESDS is creation-order/RBA-based, and RRDS is relative-record-number based.
Q4. Why is status 35 so common in production?
Because it often signals environment or definition issues such as missing DDs, wrong dataset attributes, or catalog problems.
Q5. How do you handle duplicate keys in a KSDS load?
Treat them as expected business exceptions where appropriate, or reject them with an audit trail and a remediation path.
Q6. During the processing of a VSAM file, some system error occurs and it is subsequently unusable how to fix this issue?
Run VERIFY
Q7. How do you fix the problem associated with VSAM file status out of space condition?
They are COBOL status values that report the result of VSAM file operations such as OPEN, READ, WRITE, REWRITE, DELETE, and CLOSE.
Q9. What is VSAM initialization?
It is the process of defining, deleting, verifying, and loading a VSAM cluster so it is structurally ready for application use.
Q10. How do you initialize a VSAM file in IDCAMS?
A common pattern is DELETE, DEFINE CLUSTER, and then REPRO to load data.
Q11. What does COBOL status 35 mean for VSAM?
It usually indicates an open failure or related definition problem, often involving JCL, catalog, or file attributes.
Q12. Why use a second FILE STATUS item for VSAM?
Because it provides more detailed return information than the two-byte COBOL status alone.
Q13. What is the best first step in VSAM troubleshooting?
Check the verb, the status code, the OPEN mode, and the DD/catalog definition.
VSAM mastery comes from combining correct definitions, disciplined COBOL error handling, and repeatable initialization and recovery procedures. If you standardize FILE STATUS checks, automate IDCAMS validation, and document your recovery paths, you will reduce outages and shorten triage time.
For deeper learning, explore related mainframe topics such as COBOL file handling, IDCAMS utility patterns, JCL utilities, CICS file control, and DB2 integration to build a complete enterprise data-processing toolkit.
OUTER JOIN Queries are a valuable tool in SQL, allowing you to retrieve data from…
OUTREC control statement is used to reformat (adds, deletes, or reformats fields) each record after…
DFSORT is your go‑to utility for sorting, merging, and transforming data. ICETOOL Utilities takes DFSORT…
The Product Owner role has shifted from just being a requirements proxy to a strategic,…
Business Value: In the world of Agile development, the user story has long been the…
The SAFe Scrum Master certification has become one of the most sought-after credentials for Agile…
The Professional Scrum with Kanban (PSK) course enhances your organization's ability to deliver value efficiently…
Effective User interviews play a crucial role in Scrum methodology, helping Product Owners and Scrum…
Product Owners should be well-versed in various user research tools and techniques to effectively understand…