Avoiding affinities using the DELAY and CANCEL REQID commands
The CICS DELAY command is used to suspend a task. Another task can cancel this command using the CANCEL command and specifying the REQID associated with the DELAY command.
With this CICS application programming technique, one task can resume another task that has been suspended by a DELAY command.
A DELAY request can be canceled only by a different task from the one issuing the DELAY command, and the CANCEL command must specify the REQID associated with DELAY command. Both the DELAY and CANCEL command must specify the REQID option to use this technique.
- A task (TRN1) writes a predefined DELAY REQID to a TS queue. For
example:
EXEC CICS WRITEQ TS QUEUE('DELAYQUE') FROM(reqid_value) - The task waits on another task by issuing a DELAY command, using
the
reqid_value
as the REQID. For example:
EXEC CICS DELAY INTERVAL(1000) REQID(reqid_value) - Another task, TRN2, reads the REQID of the DELAY request from TS queue called 'DELAYQUE'.
- TRN2 completes its processing, and resumes TRN1 by canceling the DELAY request.
The process using a TS queue is illustrated in Figure 1.

Another way to pass the REQID when employing this technique would be for TRN1 to start TRN2 using the START command with the FROM and TERMID options. TRN2 could then obtain the REQID with the RETRIEVE command, using the INTO option.
- Be issued in same target region as the DELAY command was executed in, or
- Specify the SYSID of the target region where the DELAY command was executed, or
- Specify a TRANSID (TRN1 in our example) that is defined as a remote transaction residing on the target region where the DELAY command was executed.
An application design based on the remote TRANSID technique only works for two target regions. An application design using the SYSID option on the cancel command only works for multiple target regions if all target regions have connections to all other target regions. In either case, the application programs need to be modified: there is no acceptable way to use this programming technique in a dynamic or distributed routing environment except by imposing restrictions on the routing program.
If the CANCEL command is issued by a transaction that is initiated from a terminal, it is possible that the transaction could be dynamically routed to the wrong target region.