Compaq COBOL AAQ2G1FTK User Manual

Page 85

Advertising
background image

Developing Compaq COBOL Programs

1.4 Program Run Messages

050-READ-MASTER.

READ INDEXED-MASTER

INVALID KEY PERFORM 100-CHECK-STATUS
GO TO 200-INVALID-READ.
.
.
.

100-CHECK-STATUS.

IF MASTER-STATUS = "23"

DISPLAY "RECORD NOT IN FILE".

IF MASTER-STATUS = "24"

DISPLAY "BOUNDARY VIOLATION OR RELATIVE RECORD
NUMBER TOO LARGE".

.
.
.

If your program contains a Declarative USE procedure for a file and an I/O
operation for that file fails, the I/O system performs the USE procedure, but does
not display an error message.

A Declarative USE procedure can sometimes avoid program termination. For
example, File Status 91 indicates that the file is locked by another program;
rather than terminate your program, you can perform other procedures and then
try reopening the file. If program continuation is not desirable, the Declarative
USE procedure can perform housekeeping functions, such as saving data or
displaying program-generated diagnostic messages.

If you specify an INVALID KEY phrase for a file and the I/O operation causes
an INVALID KEY condition, the I/O system performs the associated imperative
statement and no other file processing for the current statement. The Declarative
USE procedure (if any) is not performed. The INVALID KEY phrase processes
I/O errors due to invalid key conditions only.

If you do not specify an INVALID KEY phrase but declare a Declarative USE
procedure for the file, the I/O system performs the Declarative USE procedure
and returns control to the program.

If a severe error occurs and you do not have a Declarative Use procedure, your
program will terminate abruptly with a run-time diagnostic. For example, given
a program that looks for AFILE.DAT and that file is missing:

cobrtl: severe: file AFILE.DAT not found

In this case, program run ends because you have not handled the error with a
Declarative Use procedure.

1.4.4 I/O Errors and RMS (OpenVMS)

I/O errors are detected by the I/O system, which (for OpenVMS Alpha systems)
consists of Record Management Services (RMS) and the Run-Time Library (RTL).
You can use the RMS special registers, which contain the primary and secondary
RMS completion codes of an I/O operation, to detect errors. The RMS special
registers are as follows:

RMS-STS
RMS-STV
RMS-FILENAME
RMS-CURRENT-STS
RMS-CURRENT-STV
RMS-CURRENT-FILENAME

Developing Compaq COBOL Programs 1–55

Advertising