Status Key; Exception/Error Procedures - IBM 5280 Programmer's Manual

Distributed data system, cobol
Hide thumbs Also See for 5280:
Table of Contents

Advertisement

Status Key
The Status Key is a 2-character data-item you define in the Data Division of
your program and name in the FILE STATUS clause. In the example in
figure 5.2, PRINT-FILE-STAT at
II
and UPDATE-FILE-STAT at Bare
defined in the WORKING-STORAGE SECTION at
II.
Upon return to the COBOL program, the Status Key contains a value that
defines the status of the last request on the file.
It is recommended that you define a Status Key for all files and that your
COBOL program check the contents after each I/O request. Otherwise,
errors may go undiscovered by the program, producing results that may be
both destructive and difficult to diagnose.
If neither a Status Key nor an EXCEPTION/ERROR procedure (described
in the next section) is present and an error occurs, the program will display a
message in the Status Line at the top of the screen. A message identifier in
the format 92nn will precede the message; nn is the code that would have been
placed in the Status Key had it been present.
See Appendix B for a complete list of the values that can be placed in the
Status Key, their meanings, and a cross-reference between Status Key values
and the message identifiers as displayed in the Status Line.
EXCEPTION / ERROR Procedures
You can also code a procedure to handle errors using the
EXCEPTION /ERROR declarative. In the example in figure 5.2, each time
an error occurs on UPDATE-FILE or PRINT-FILE, an
ERROR/EXCEPTION routine at
II
or
EJ
receives control, displays some
messages, and stops the run.
The EXCEPTION /ERROR procedure is used only when a file is in open
status. Therefore, if any operation is attempted against a file which has
already been closed, or was never opened, then the EXCEPTION /ERROR
procedure is not executed. COBOL will return a Status Key value of 92.
Chapter 5. Diskette Input/Output
5- 7

Advertisement

Table of Contents
loading

Table of Contents