Coding The Status Key; Exception/Error Procedures; Example Using Status Key And Error Procedures; Return Information - IBM 5280 Programmer's Manual

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

Advertisement

Coding the Status Key
To code the status key:
1. Relate FILE STATUS and a data-item in the SELECT clause as shown
below and in
fJ
in figure 3.2:
FILE STATUS IS TUBE-STAT
2. Code a data-item in Working Storage Section or the Linkage Section as
shown below and at
D
in figure 3.2:
77 TUBE-STAT
PIC XX.
After each READ, WRITE, OPEN, and CLOSE operation, a return code
posted in the status key shows the outcome of the operation. Your program
can look at the status key, and then take the appropriate action.
The return codes for transaction I/O are the same as those for
SEQUENTIAL I/O. The return codes and their meaning are given in
Appendix B.
Exception / Error Procedures
You can also code a procedure to handle errors using the
EXCEPTION /ERROR declarative, as shown at
I!I
and and
II
in figure 2.3.
The procedure, WORK-STATION, takes control each time an error or
exception occurs on SCREEN-FILE-PR3. You can include code in the
procedures to diagnose the error, and take subsequent action in consideration
of the error. 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.
The USE FOR DEBUGGING declarative (coded before the
EXCEPTION/ERROR procedures) and other debugging aids are described
in Chapter 9.
Example Using Status Key and ERROR Procedures
Return Information
In the example in figure 3.3, the procedure WORK-STATION at
I!I
receives
control each time a nonzero return code is placed in the status key. The
procedure displays a message and the value in the status key, and then stops
the run.
Two different types of information can be returned to a COBOL program
after a transaction I/O operation in the following areas:
Attribute Data Area, which provides information on the status of the
terminal which loaded your program. You will probably need this
information only when (1) your installation has different size (1920-,
960-, and/or 480-character) screens and (2) your program needs to
know the size of the screen at the data station to which it is writing
screen images.
Work Station Control Area, which contains a special code when control
is returned to the COBOL program from the work station. The code
indicates which function or command key the operator pressed. The
command keys and their corresponding codes are given in figure 1.3 and
1.4 in Chapter
1.
Chapter 3. Transaction I/0 - Writing the COBOL Program
3- 5

Advertisement

Table of Contents
loading

Table of Contents