Compaq COBOL AAQ2G1FTK User Manual

Page 243

Advertising
background image

Handling Input/Output Exception Conditions

7.2 Planning for the Invalid Key Condition

in the file, or when you receive the AT END condition for a subsequent read
operation, indicating that no more records exist in the file.

Example 7–2 Handling the Invalid Key Condition

.
.
.
MOVE "SMITH" TO LAST-NAME TEST-LAST-NAME.
MOVE "Y" TO ANY-MORE-DUPLICATES.
PERFORM A500-READ-DUPLICATES

UNTIL ANY-MORE-DUPLICATES = "N".

.
.
.
STOP RUN.

A500-READ-DUPLICATES.

READ INDEXED-FILE RECORD INTO HOLD-RECORD

KEY IS LAST-NAME
INVALID KEY

MOVE "N" TO ANY-MORE-DUPLICATES
DISPLAY "Name not in file!"

NOT INVALID KEY

PERFORM A510-READ-NEXT-DUPLICATES

UNTIL ANY-MORE-DUPLICATES = "N"

END-READ.

A510-READ-NEXT-DUPLICATES.

READ INDEXED-FILE NEXT RECORD

AT END MOVE "N" TO ANY-MORE-DUPLICATES
NOT AT END

PERFORM A520-VALIDATE

END-READ.

IF ANY-MORE-DUPLICATES = "Y" PERFORM A700-PRINT.

A520-VALIDATE.

IF LAST-NAME NOT EQUAL TEST-LAST-NAME

MOVE "N" TO ANY-MORE-DUPLICATES.

END READ.

A700-PRINT.

.
.
.

7.3 Using File Status Values and OpenVMS RMS Completion Codes

Your program can check for the specific cause of the failure of a file operation
by checking for specific file status values in its exception handling routines. To
obtain Compaq COBOL file status values, use the FILE STATUS clause in the
file description entry.

On OpenVMS, to access RMS completion codes, use the Compaq COBOL special
registers RMS-STS and RMS-STV, or RMS-CURRENT-STS and RMS-CURRENT-
STV.

Handling Input/Output Exception Conditions 7–3

Advertising