DELAY
DELAY
The CICS DELAY statement is used to delay the execution of a task (transaction) for a specified amount of time. It allows timing control within a transaction, ensuring that specific actions occur after a delay. The default value is INTERVAL(0).
Syntax -
EXEC CICS DELAY
[INTERVAL(hhmmss)]
[TIME(hhmmss)]
[FOR HOURS(hh) | MINUTES(mm) | SECONDS(ss)]
[UNTIL HOURS(hh) | MINUTES(mm) | SECONDS(ss)]
[REQID(request-id)]
[RESP(response-field)]
[RESP2(response-field2)]
END-EXEC.
- INTERVAL(hhmmss) - Specifies the time interval to elapse from the time when the DELAY command is issued.
- TIME(hhmmss) - Specifies the time when the task should resume processing.
- HOURS(hh) - Specifies the hours range from 0–99.
- MINUTES(mm) - Specifies value in the range from 0–59, when HOURS or SECONDS are also coded. Specifies value in the range from 0–5999 when MINUTES is the only option coded.
- SECONDS(ss) - Specifies value in the range from 0–59, when HOURS or MINUTES are also coded. Specifies value in the range from 0–359 999 when SECONDS is the only option coded.
- SYSID(system-name) - Specifies the system name to which the request is directed.
- REQID(name) - Specifies a unique name (1–8 characters) to identify the DELAY request.
- RESP(response-variable) - Optional. It captures the response code of the DELAY operation and used to check if the command executed successfully or encountered an error.
- RESP2(response2-variable) - Optional. It captures the response2 code of the DELAY operation when the error occured.
Short Examples -
Scenario - Pausing Execution for 10 Seconds
...
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-TRANS-ID PIC X(4) VALUE 'TRN1'.
01 WS-RESP PIC S9(4) COMP.
PROCEDURE DIVISION.
EXEC CICS DELAY
INTERVAL(000010) *> Wait for 10 seconds
RESP(WS-RESP)
END-EXEC.
IF WS-RESP = DFHRESP(NORMAL) THEN
...
ELSE
...
END-IF.
...
The program starts execution and displays a message. The DELAY command pauses execution for 10 seconds (INTERVAL(000010)). After 10 seconds, execution resumes, and a message is displayed. The response code (RESP) is checked to confirm successful execution.
Error Conditions -
Eror Condition | RESP | RESP2 | Reason |
---|---|---|---|
INVREQ | 16 | 4 | Hours are out of range. |
16 | 5 | Minutes are out of range. | |
16 | 6 | Seconds are out of range. | |
EXPIRED | 31 | Occurs if the time specified has already expired when the command is issued. |