4 using declarative use procedures – Compaq COBOL AAQ2G1FTK User Manual

Page 248

Advertising
background image

Handling Input/Output Exception Conditions
7.3 Using File Status Values and OpenVMS RMS Completion Codes

Example 7–5 (Cont.) Referencing RMS-STS, RMS-STV, RMS-CURRENT-STS,

and RMS-CURRENT-STV Codes (OpenVMS)

A903-REPORT-RMS-CURRENT-STATUS.
*******************************************
*

DISPLAY "RMS-CURRENT-STS = " RMS-CURRENT-STS WITH CONVERSION.
DISPLAY "RMS-CURRENT-STV = " RMS-CURRENT-STV WITH CONVERSION.
DISPLAY "RMS-CURRENT-FILENAME = " RMS-CURRENT-FILENAME.

*
*******************************************

PERFORM A999-GET-ANSWER UNTIL ANSWER = "Y" OR "N".
IF ANSWER = "N" STOP RUN.

A904-MOVE-RMS-STS-STV.
*******************************************
*

MOVE RMS-STS OF FILE-1 TO STS.
MOVE RMS-STV OF FILE-1 TO STV.

*
*******************************************

PERFORM A999-GET-ANSWER UNTIL ANSWER = "Y" OR "N".
IF ANSWER = "N" STOP RUN.

A999-GET-ANSWER.

DISPLAY "Do you want to continue?"
DISPLAY "Please answer Y or N"
ACCEPT ANSWER.

7.4 Using Declarative USE Procedures

An applicable Declarative USE procedure executes whenever an I/O statement
results in an exception condition (a file status value that does not begin with
a zero ( 0 )) and the I/O statement does not contain an AT END or INVALID
KEY phrase. The AT END and INVALID KEY phrases take precedence over
a Declarative USE procedure, but only for the I/O statement that includes the
clause. For example, the AT END phrase takes effect only with File Status 10
and the INVALID KEY phrase takes effect only with File Status 23. Therefore
you can have specific I/O statement exception condition handling for a file and
also include a Declarative USE procedure for general exception handling.

A Declarative USE procedure is a set of one or more special-purpose sections at
the beginning of the Procedure Division. As shown in Example 7–6, the key word
DECLARATIVES precedes the first of these sections, and the key words END
DECLARATIVES follow the last.

7–8 Handling Input/Output Exception Conditions

Advertising