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
.
.
.
STOP RUN.
A500-READ-DUPLICATES.
READ INDEXED-FILE RECORD INTO HOLD-RECORD
END-READ.
A510-READ-NEXT-DUPLICATES.
READ INDEXED-FILE NEXT RECORD
END-READ.
A520-VALIDATE.
IF LAST-NAME NOT EQUAL TEST-LAST-NAME
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.2 Planning for the Invalid Key Condition
UNTIL ANY-MORE-DUPLICATES = "N".
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"
AT END MOVE "N" TO ANY-MORE-DUPLICATES
NOT AT END
PERFORM A520-VALIDATE
IF ANY-MORE-DUPLICATES = "Y" PERFORM A700-PRINT.
MOVE "N" TO ANY-MORE-DUPLICATES.
Handling Input/Output Exception Conditions 7–3
Need help?
Do you have a question about the COBOL AAQ2G1FTK and is the answer not in the manual?
Questions and answers