Switching from sending to receiving data
There are several ways of switching from send state to receive state .
One possibility is to use a RECEIVE command. The state tables show that CICS supplies the INVITE and WAIT when a SEND is followed immediately by a RECEIVE.
Another possibility is to use a SEND INVITE command. The state tables show that after SEND INVITE the conversation switches to pendreceive state (state 3). The column for state 3 shows that a WAIT CONVID command switches the conversation to receive state (state 5).
Still another possibility is to specify the INVITE and WAIT options on the SEND command. The state tables show that after SEND INVITE WAIT, the conversation switches to receive state (state 5).
* ...
DATA DIVISION.
WORKING-STORAGE SECTION.
* ...
01 FILLER.
02 WS-RESP PIC S9(7) COMP.
02 WS-STATE PIC S9(7) COMP.
* ...
PROCEDURE DIVISION.
* ...
* Check return code from SEND INVITE WAIT
IF WS-RESP = DFHRESP(NORMAL)
THEN
* ... Request successful
IF EIBERR = LOW-VALUES
THEN
* ... No errors, check state
IF WS-STATE = DFHVALUE(RECEIVE)
THEN
* ... SEND OK, continue processing
ELSE
* ... Logic error, should never happen
END-IF
ELSE
* ... Error indicated
EVALUATE WS-STATE
WHEN DFHVALUE(ROLLBACK)
* ... ROLLBACK received
WHEN DFHVALUE(RECEIVE)
* ... ISSUE ERROR received, reason in EIBERRCD
WHEN OTHER
* ... Logic error, should never happen
END-EVALUATE
END-IF
ELSE
* ... Examine RESP code for source of error.
END-IF.