The way VSAM handles error conditions , many I/O errors that cause COBOL program to abend when we use non-VSAM access method do not cause an abend when we use VSAM.Instead the file status is being used to indicate the nature of the problem. Depending upon nature of the problem, an error message may or may not printed by VSAM in the spool and finally this might led to serious errors to go undetected.
Let us take an example where a serious error will occur and it will be un noticed. Suppoes a KSDS file is originally defined with 8000 records.Now if the file has grown upto 7800 records and next time when the program loads the VSAM file and if it has to load 4000rec records then VSAM will start writing the warning message after writing the first 200 records. the rest 200 records will not be written on the file and job also completed successfully after writing the rest 200 warning messages in the spool and the last 200 transactions haven’t been added to the file.
The only way to avoid problem like this is to test the FILE STATUS code after every I/O statements for a VSAM file to make sure that no error occurred. Use IF statement that test the file status codes.Then ,you can check for expected errors like no-record-found conditions as well as unexpected errors that cause the serious problems. The below list deals with the error handling rountines for VSAM file processings:
File Status Code | OPEN | CLOSE | READ | WRITE | REWRITE | DELETE | START | Recommended action |
0 |
File successfully opened | File successfully closed | File successfully read | File successfully written | File successfully rewritten | File successfully deleted | Successful Completion | Continue processing |
2 |
Vaild duplicate alternate key | Vaild duplicate alternate key | Vaild duplicate alternate key | Continue processing | ||||
10 |
End of file reached | Normal AT END processing | ||||||
21 |
Record out of sequence (sequential access only) | Print error message and continue | ||||||
22 |
Duplicate key | Print error message and continue | ||||||
23 |
Record no found | Record no found | Specified key not found | Print error message and continue | ||||
24 |
No more Space allocated to file | Terminate the job | ||||||
30 |
Uncorrectable I/O error | Uncorrectable I/O error | Uncorrectable I/O error | Uncorrectable I/O error | Uncorrectable I/O error | Uncorrectable I/O error | Uncorrectable I/O error | Terminate the job |
90 |
Unusable file;possibly an empty opened as INPUT as I-O | VSAM logic error | VSAM logic error | VSAM logic error | VSAM logic error | VSAM logic error | VSAM logic error | Terminate the job |
91 |
Password Failure | Terminate the job | ||||||
92 |
File already opened | File not open | File not open or end of file already reached | File not open ; incorrect key for EXTEND file | File no open;no previous READ | File no open;no previous READ(sequential access) | Invalid request;probably file not open | Terminate the job |
93 |
Not enough storage for VSAM task, or file contention problem | Not enough storage for VSAM task, or file contention problem | Not enough storage for VSAM task, or file contention problem | Not enough storage for VSAM task, or file contention problem | Not enough storage for VSAM task, or file contention problem | Not enough storage for VSAM task, or file contention problem | Not enough storage for VSAM task, or file contention problem | Terminate the job |
95 |
Conflicting the attributes | Terminate the job | ||||||
96 |
No DD or DLBL statement | Terminate the job | ||||||
97 |
File not closed by previous job | Terminate the job |