Compaq AAQ2G1FTK Marine Radio User Manual


 
Handling Input/Output Exception Conditions
7.3 Using File Status Values and OpenVMS RMS Completion Codes
Example 73Dening a File Status for a File
DATA DIVISION.
FILE SECTION.
FD INDEXED-FILE
FILE STATUS IS INDEXED-FILE-STATUS.
01 INDEXED-RECORD PIC X(50).
WORKING-STORAGE SECTION.
01 INDEXED-FILE-STATUS PIC XX.
01 ANSWER PIC X.
7.3.1 File Status Values
The run-time execution of any Compaq COBOL file processing statement results
in a two-digit file status value that reports the success or failure of the COBOL
statement. To access this file status value, you must specify the FILE STATUS
clause in the file description entry, as shown in Example 7–3.
The program can access this file status variable, INDEXED-FILE-STATUS,
anywhere in the Procedure Division, and depending on its value, take a specific
course of action without terminating the program. Notice that in Example 7–4 (in
paragraph A900-EXCEPTION-HANDLING-ROUTINE), the file status that was
defined in Example 7–3 is used. However, not all statements allow you to access
the file status value as part of the statement. Your program has two options:
Build an error recovery routine into the statement. The relative and indexed
file processing statements that allow you to do this within the INVALID KEY
phrase are DELETE, READ, REWRITE, START, and WRITE (that is, all the
record I-O verbs except READ NEXT). See Example 7–4.
Define a Declarative USE procedure to handle the condition. This option
is available for all file organizations and their I/O statements. (See
Example 7–6, Example 7–7, and Example 7–8.)
Example 74 Using the File Status Value in an Exception Handling Routine
PROCEDURE DIVISION.
A000-BEGIN.
.
.
.
DELETE INDEXED-FILE
INVALID KEY MOVE "Bad DELETE" to BAD-VERB-ID
PERFORM A900-EXCEPTION-HANDLING-ROUTINE.
.
.
.
READ INDEXED-FILE NEXT RECORD
AT END MOVE "Bad READ" TO BAD-VERB-ID
PERFORM A900-EXCEPTION-HANDLING-ROUTINE.
.
.
.
(continued on next page)
74 Handling Input/Output Exception Conditions