VSAM - Handling errors in input and output operations - www.cadcobol.com.br



Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

Handling errors in input and output operations

Enterprise COBOL for z/OS, Version 4.2, Programming Guide


When an input or output operation fails, COBOL does not automatically take corrective action.
You choose whether your program will continue running after a less-than-severe input or output error.

You can use any of the following techniques for intercepting and handling certain input or output conditions or errors:

  • End-of-file condition (AT END)
  • ERROR declaratives
  • FILE STATUS clause and file status key
  • File system status code
  • Imperative-statement phrases on READ or WRITE statements

    For VSAM files, if you specify a FILE STATUS clause, you can also test the VSAM status code to direct your program to error-handling logic.

  • INVALID KEY phrase

To have your program continue, you must code the appropriate error-recovery procedure. You might code, for example, a procedure to check the value of the file status key. If you do not handle an input or output error in any of these ways, a severity-3 Language Environment condition is signaled, which causes the run unit to end if the condition is not handled.

The following figure shows the flow of logic after a VSAM input or output error:

The following figure shows the flow of logic after an input or output error with QSAM or line-sequential files.
The error can be from a READ statement, a WRITE statement, or a CLOSE statement with a REEL/UNIT clause (QSAM only).

*Possible phrases for QSAM are AT END, AT END-OF-PAGE, and INVALID KEY; for line sequential, AT END.

**You need to write the code to test the file status key.

***Execution of your COBOL program continues after the input or output statement that caused the error.

Related tasks



© Copyright IBM Corp.