Indicator Example - IBM 5280 Programmer's Manual

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

Advertisement

Indicator Example
An example of the use of transaction I/O and indicators is shown in figure
3.3. (See the 5280 COBOL Language Reference manual under "OCCURS
Clause" and "INDICATOR Clause" for detailed rules on coding the
INDICATOR clause with a data-item.)
The logic of the program shown in figure 3.3 is as follows:
The program writes four fields to the screen on succeeding lines in the
following order: ENAME, STRAD, CTYST, and EMPNO. The cursor
appears in the first position of the first field, ENAME.
The operator enters the employee name, street address, city and state,
and employment number in the designated fields and presses the Enter
key.
The program checks whether or not the employee number entered by the
operator is valid.
If the employee number is valid, the program updates EMPMAS-FILE
and writes a fresh screen format.
If the employee number is not valid, (1) the program writes an error
message to the screen indicating that the number entered isn't valid and
(2) writes a screen format with the information previously entered. The
cursor bypasses the ENAME, STRAD, and CTYST fields and appears
in the first position of the EMPNO field.
The use of indicators allows the program to control whether or not ENAME,
STRAD, and CTYST are bypassed by the cursor. The following text explains
how this is achieved:
1. The indicators 51, 52, and 53 are coded on secondary lines of the
statements at
II, II,
and
II
with the CHECK(BY) keyword. The
secondary lines follow immediately after the lines that define the fields
to be bypassed.
2. The indicator numbers 51, 52, and 53 are associated with a boolean
data-item defined at
II.
3. Before an error message is written, the indicators are set to on at
D.
4. The WRITE statement at
II
contains the related INDICATOR clause
which writes the new screen format and causes the cursor the bypass the
ENAME, STRAD, and CTYST fields.
Chapter 3. Transaction I/O - Writing the COBOL Program
3- 13

Advertisement

Table of Contents
loading

Table of Contents