Processing the mapped input
This example shows you how the input subfields are used, using the "quick update" program.
To illustrate how the input subfields are used, we return to “quick
update”. After we have the input, we need to do some checks on it
before continuing. First, we require that the charge be entered (that
is, that the input length be greater than zero), and be positive and
numeric.
IF CHGL = 0, MOVE -1 TO CHGL
MOVE 1 TO ERR-NO
ELSE IF CHGI NOT > ZERO OR CHGI NOT NUMERIC,
MOVE DFHUNIMD TO CHGA,
MOVE -1 TO CHGL
MOVE 2 TO ERR-NO.
The
'MOVE -1'
statements
here and following put the cursor in the first field in error when
we redisplay the map, as explained in
Positioning the cursor
. The
message number tells us what message to put in the message area; 1
is “enter a charge”, and so on, through 6, for “charge is over limit”.
We do these checks in roughly ascending order of importance, to
ensure
that the most basic error is the one that gets the message. At the
end of the checking, we know that everything is okay if ERR-NO is
zero.
An account number must be entered, as well as the charge. If we
have one (whatever the condition of the charge), we can retrieve the
customer's
account record to ensure that the account exists:
IF ACCTNOL = 0, MOVE -1 TO ACCTNOL
MOVE 3 TO ERR-NO
ELSE EXEC CICS READ FILE (ACCT) INTO (ACCTFILE-RECORD)
RIDFLD (ACCTNOI) UPDATE RESP(READRC) END-EXEC
IF READRC = DFHRESP(NOTFOUND), MOVE 4 TO ERR-NO,
MOVE DFHUNIMD TO ACCTNOA
MOVE -1 TO ACCTNOL
ELSE IF READRC NOT = DFHRESP(NORMAL) GO TO HARD-ERR-RTN.
If
we get this far, we continue checking, until an error prevents us
from going on. We need to ensure that the operator gave us a good
account number (one that is not in trouble), and that the charge is
not too much for the account:
IF ERR-NO NOT > 2
IF ACCTFILE-WARNCODE = 'S', MOVE DFHBMBRY TO MSGA
MOVE 5 TO ERR-NO
MOVE -1 TO ACCTNOL
EXEC CICS LINK PROGRAM('NTFYCOPS') END-EXEC
ELSE IF CHGI > ACCTFILE-CREDIT-LIM - ACCTFILE-UNPAID-BAL
- ACCTFILE-CUR-CHGS
MOVE 6 TO ERR-NO
MOVE -1 TO ACCTNOL.
IF ERR-NO NOT = 0 GO TO REJECT-INPUT.