Sending data to the partner transaction
Data is sent to the partner transaction using the SEND command.
The SEND command is valid only in send state (state 2). Because a successful simple SEND leaves the conversation in send state (state 2), it is possible to issue a number of successive sends. The data from the simple SEND command is initially stored in a local CICS® buffer which is “flushed” either when this buffer is full or when the transaction requests transmission. The transaction can request transmission either by using a WAIT CONVID command or by using the WAIT option on the SEND command. The reason data transmission is deferred is to reduce the number of calls to the network. However, the application should use WAIT if the partner transaction requires the data to continue processing.
* ...
DATA DIVISION.
WORKING-STORAGE SECTION.
* ...
01 FILLER.
02 WS-CONVID PIC X(4).
02 WS-STATE PIC S9(7) COMP.
* ...
01 FILLER.
02 WS-SEND-AREA PIC X(70).
02 WS-SEND-LEN PIC S9(4) COMP VALUE +70.
* ...
01 FILLER.
02 WS-RCVD-AREA PIC X(100).
02 WS-MAX-LEN PIC S9(4) COMP VALUE +100.
02 WS-RCVD-LEN PIC S9(4) COMP VALUE +0.
* ...
PROCEDURE DIVISION.
* ...
EXEC CICS SEND CONVID(WS-CONVID) STATE(WS-STATE)
FROM(WS-SEND-AREA) LENGTH(WS-SEND-LEN)
END-EXEC.
* ... Check outcome of SEND.
* ...
*
EXEC CICS SEND CONVID(WS-CONVID) STATE(WS-STATE)
INVITE WAIT
END-EXEC.
* ...
* Receive data from the partner transaction.
*
EXEC CICS RECEIVE CONVID(WS-CONVID) STATE(WS-STATE)
INTO(WS-RCVD-AREA) MAXLENGTH(WS-MAX-LEN)
NOTRUNCATE LENGTH(WS-RCVD-LEN)
END-EXEC.
*
* ... Check outcome of RECEIVE.
* ...