IMS to CICS using the RECEIVE EXEC command
When IMS has a reply
to send to CICS® that results
from a message sent by CICS with SEND
LAST (ATTACH BB/EB), IMS sends that message using the ATTACH function
management header and BB/EB. In order to receive the message from
the session, CICS must initiate
a new transaction (or a new instance of the original transaction)
that uses the RECEIVE EXEC command for this purpose.
The general CICS application program flow for this is shown in the following figure.

The reply from IMS is returned synchronously on the session (with the ATTACH FM header) and carries BB/EB. A recoverable reply carries RQD2; a nonrecoverable reply carries RQD1. The RPROCESS (RDPN) and RRESOURCE (RPRN) fields sent to IMS are automatically wrapped by IMS into the DPN and PRN fields of the outbound ATTACH FMH.
CICS examines the returned
reply and uses the DPN, or the first four characters of the data,
to determine the transaction that can process the returned reply. RECEIVE is
used to obtain the IMS reply
from the session. The PRN field is passed to the initiated transaction,
indicating the terminal to which the returned reply is to be sent.
After issuing RECEIVE, the application program
must save and check the values in the EXEC interface block (EIB) before
performing any additional processing.
CICS must schedule an asynchronous
transaction to send the returned reply to the terminal by issuing
a START command. The transaction that is initiated
is brought up, and owns the terminal to which the reply is to be sent.
This asynchronous transaction uses the START interface
to communicate with the terminal, and all processing within this transaction
occurs asynchronously to the transaction that initiated it. If the
transaction that sends output to the terminal is scheduled successfully,
the originating application now issues a sync point (SYNCPOINT), if
required. Issuing this sync point causes an appropriate response to
be returned to the IMS transaction
reply. If the transaction is not scheduled successfully, issuing the
sync point causes an appropriate exception response to be returned
to the IMS transaction reply.
If CICS wants to perform any
application processing based upon the contents of the IMS reply message, that processing is performed
before the sync point is issued. This ensures that CICS resources and IMS resources
are committed in synchronism.
If the processing completes successfully, the application program
must free the session using either a FREE or RETURN EXEC
command.