File status and transactions
| Common STATUS codes | |
| Commit points | |
| Recovery |
Common STATUS codes
Every I/O verb fills the FILE STATUS field: 00 success, 10 end of file, 21 duplicate key, 22 write on existing key, 23 read of missing key, 30 permanent error, 35 file not found. Test it after every verb in production code:
READ EMPLOYEE-FILE
AT END MOVE "Y" TO WS-EOF
END-READ.
IF WS-STATUS NOT = "00"
PERFORM HANDLE-FILE-ERROR
END-IF.
Commit points
For update files, decide where a unit of work ends and commit there. On a CICS system that is EXEC CICS SYNCPOINT; on batch files it means closing and reopening at a known-good record boundary.
Recovery
Keep a restart position: the last committed key in a small file, so a failed job resumes instead of reprocessing the whole input. Log the key at each commit, and check it before the first READ.
Next: Db2 in practice
Article author: Arthur Isaev