# CICS Request/Reply

This section explains CICS Request/Reply (CRR) operations. The CICS Request/Reply facility provides an easy-to-use method for requesting information from ESB services.

A request can be sent by any business process simply by calling `SXCREQR`. The business process is a CICS program written in COBOL, C, PL1, or Assembler. The basic flow is as follows:

1. The business process formats a SXCREQR parameter list. This tells `SXCREQR` where the outgoing data is, where to put the response, and how long to wait for the response.
2. The business process then does a CICS `LINK` to SXCREQR with a parameter list in `COMMAREA`.
3. When SXCREQR returns to the business process, either the response data is presented or an error is indicated.

Note: `USERHLQ.COB(SXCCIRR1)` provides an example of a COBOL program using SXCREQR.

The size of the input to SXCREQR is limited to the size of the `COMMAREA`. The outgoing message size is limited to the value of the RR-MAXSIZE control parameter in the CICS interface definition for Substation ES. This normally is 8192, but can be changed to a value from 2048 to 32000.

The output can be returned as data in the same `COMMAREA` as the input, or to a TSQ or storage pointer.

## Detailed Flow

The following steps gives the Request/Reply flow in more detail:

1. In the CICS user program, configure the SXCREQR parameter.
2. In the CICS user program, link to SXCREQR with parameters and data in `COMMAREA`.
3. SXCREQR validates parameters and returns an error code if any are invalid.
4. SXCREQR gets a CRR token. There are 100 of these reusable tracking control blocks available.
5. SXCREQR creates a TSQ entry for user data.
6. SXCREQR posts an ECB, which wakes up `SXCOSRVA`, a Substation ES administration program.
7. If one is not already active, SXCREQR starts an SXTO transaction for timeout processing.
8. SXCREQR waits for a response, either from the timeout module or the response module.
9. The `SXCOSRVA` task returns to Substation ES indicating an `S SXCREQR` event.
10. Substation ES starts a new transaction for program `SXCOSRVT`.
11. `SXCOSRVT` gets data from TSQ and returns the data to Substation ES.
12. Substation ES finds a matching trigger definition using a buffer value match.
13. Substation ES publishes message according to the trigger definition, using the `tibss-envelope` value.
14. The ESB process gets the message, processes it, and issues a response message that includes the `tibss-envelope`.
15. Substation ES consumes the response message using a recipe definition.
16. Substation ES starts a new transaction in CICS for `SXCREPLY` using the response data and envelope.
17. `SXCREPLY` finds the correct CRR token using the envelope value.
18. `SXCREPLY` moves the response data to the appropriate area, whether the COMMAREA, TSQ, or Storage Pointer, and posts the SXCREQR ECB.
19. SXCREQR wakes up and returns to caller.
20. The CICS user program can now process the response data or error condition.

Copyright © TIBCO Software Inc. All rights reserved.