Input-Output Error Handling Procedures [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
Input-Output Error Handling Procedures
Input-output error handling procedures are controlled by the following
programming options in the sequence shown.
* First, the FILE STATUS item (if declared) is set for the
associated file.
* Second, the INVALID KEY, AT END, or AT EOP phrases on selected I-O
statements are executed.
* Third, if no INVALID KEY, AT END, or AT EOP is executed, a USE
statement and its associated procedure is executed.
Ten input-output statements allow exception condition processing with
a[REV BEG] USE procedure, a FILE STATUS item, or the INVALID KEY, AT END,
or AT EOP phrases. Table 8-6 lists these statements and the kinds of
exception condition processing each one can use.[REV END]
Table 8-6. Input-Output Statements and Exception Condition Options
---------------------------------------------------------------------------------
| | | | |
| | | | INVALID KEY |
| | | FILE STATUS | AT END |
| Statement | USE Procedure | Item | AT EOP |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| CLOSE | Yes | Yes | No |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| DELETE | Yes | Yes | Yes |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| EXCLUSIVE | Yes | Yes | No |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| OPEN | Yes | Yes | No |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| READ | Yes | Yes | Yes |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| RETURN | No | No | Yes |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| REWRITE | Yes | Yes | Yes |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| START | Yes | Yes | Yes |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| UN-EXCLUSIVE | Yes | Yes | No |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| WRITE | Yes | Yes | Yes |
| | | | |
---------------------------------------------------------------------------------
If an exception condition occurs and:
* Neither a FILE STATUS item, USE statement procedure, INVALID KEY
or AT END phrase is specified, the program is aborted along with a
file system tombstone display.
* An INVALID KEY or AT END phrase is specified, with no USE
statement specification, and an INVALID KEY or AT END condition
occurs, the program continues executing in-line code. If a USE
procedure was specified, it is executed.
* There are any errors in DISPLAY, ACCEPT (without ON INPUT ERROR),
SORT, MERGE and RELEASE, the program aborts.
These precedence rules are also defined in Figure 8-5 , which includes
tests for the ANSI COBOL'85 clauses NOT INVALID KEY and NOT AT END.
Figure 8-5. Input-Output Error Handling
MPE/iX 5.0 Documentation