CICS Interval Control: START, CANCEL, DELAY, ASKTIME — Complete Guide

Introduction: Time-Based Transaction Control in CICS
Most CICS transactions are initiated by a user typing a transaction ID or by ATI (Automatic Transaction Initiation) when a TD queue reaches its trigger level. But some business requirements demand time-based triggers: retry a failed operation after 30 seconds, start an end-of-day summary at 11 PM, poll an external system every 5 minutes, or implement a transaction timeout handler. CICS Interval Control provides the commands to handle all of these scenarios.
Interval Control is a group of CICS commands that manage time and scheduled transaction starts: ASKTIME (get current time), FORMATTIME (format time values), DELAY (suspend current task), START (schedule a future transaction), CANCEL (cancel a pending START), and RETRIEVE (receive data in a STARTed transaction). Together, these commands provide complete control over time-driven processing in CICS.
EXEC CICS ASKTIME: Getting the Current Time
ASKTIME returns the current date and time as a packed-decimal absolute time value (ABSTIME):
WORKING-STORAGE SECTION.
01 WS-ABSTIME PIC S9(15) COMP-3 VALUE ZERO.
01 WS-DATE PIC X(10).
01 WS-TIME PIC X(08).
01 WS-TIMESTAMP PIC X(20).
PROCEDURE DIVISION.
GET-CURRENT-TIME.
EXEC CICS ASKTIME
ABSTIME(WS-ABSTIME)
END-EXEC.ABSTIME is the number of milliseconds since January 1, 1900 at midnight. It is not human-readable on its own — use FORMATTIME to convert it to a usable format.
EXEC CICS FORMATTIME: Formatting Dates and Times
FORMATTIME converts an ABSTIME value to human-readable date and time formats:
FORMAT-CURRENT-TIME.
EXEC CICS ASKTIME ABSTIME(WS-ABSTIME) END-EXEC
EXEC CICS FORMATTIME
ABSTIME(WS-ABSTIME)
DDMMYYYY(WS-DATE) *> DD/MM/YYYY format
DATESEP('/') *> Date separator
TIME(WS-TIME) *> HH:MM:SS
TIMESEP(':') *> Time separator
FULLDATE(WS-TIMESTAMP) *> Full date-time string
END-EXEC
*── WS-DATE = '21/04/2026'
*── WS-TIME = '14:32:07'
*── WS-TIMESTAMP = '21/04/2026 14:32:07'
CONTINUE.FORMATTIME output options include:
DDMMYYYY— day-month-yearMMDDYYYY— month-day-year (US format)YYYYMMDD— ISO 8601 sortable formatYYDDD— Julian dateTIME— HH:MM:SSDATESEP(char)/TIMESEP(char)— separator character
EXEC CICS DELAY: Suspending a Task
DELAY pauses the current task for a specified time interval. The task stays alive but is not dispatched until the delay expires:
*── Wait 2 seconds before retrying ─────────────────────────────
RETRY-AFTER-DELAY.
EXEC CICS DELAY
INTERVAL(2) *> 2 seconds
RESP(WS-RESP)
END-EXEC
PERFORM RETRY-OPERATION.Alternatively, specify hours, minutes, and seconds:
EXEC CICS DELAY
FOR HOURS(0) MINUTES(0) SECONDS(30)
RESP(WS-RESP)
END-EXEC.Important caution: DELAY is a resource-holding wait. The task retains its WORKING-STORAGE, any open browse cursors, and possibly held locks for the entire delay duration. In an OLTP environment, frequent use of DELAY can exhaust the CICS task limit and degrade performance. For delays longer than a few seconds, use START/RETRIEVE (schedule a new task) rather than DELAY.
EXEC CICS START: Scheduling a Future Transaction
START schedules a CICS transaction to begin at a specified time or after a specified interval. It can optionally pass data to the started transaction:
START After an Interval
WORKING-STORAGE SECTION.
01 WS-REQID PIC X(16). *> Unique request ID for CANCEL
01 WS-DATA.
05 WS-DATA-KEY PIC X(6).
05 WS-DATA-RETRY PIC 9(2).
PROCEDURE DIVISION.
SCHEDULE-RETRY.
MOVE '000100' TO WS-DATA-KEY
ADD 1 TO WS-RETRY-COUNT
MOVE WS-RETRY-COUNT TO WS-DATA-RETRY
*── Generate a unique request ID for this START ──────────────
STRING EIBTRNID EIBTRMID DELIMITED SIZE INTO WS-REQID
EXEC CICS START TRANSID('RTRY')
AFTER HOURS(0) MINUTES(0) SECONDS(30)
FROM(WS-DATA)
LENGTH(LENGTH OF WS-DATA)
REQID(WS-REQID)
RESP(WS-RESP)
END-EXEC
IF WS-RESP = DFHRESP(NORMAL)
MOVE 'RETRY SCHEDULED IN 30 SECONDS.' TO WS-MSG
ELSE
PERFORM HANDLE-START-ERROR
END-IF.START At an Absolute Time
*── Schedule end-of-day processing at 23:00 ─────────────────────
SCHEDULE-EOD-PROCESSING.
EXEC CICS START TRANSID('EODX')
AT HOURS(23) MINUTES(0) SECONDS(0)
RESP(WS-RESP)
END-EXEC.START Key Options
| Option | Purpose |
|---|---|
| TRANSID | Transaction ID to start |
| AT HOURS/MINUTES/SECONDS | Start at this absolute clock time today |
| AFTER HOURS/MINUTES/SECONDS | Start after this interval from now |
| INTERVAL(n) | Start after n seconds (shorthand) |
| FROM / LENGTH | Data to pass to the started transaction |
| TERMID | Start the transaction at this terminal |
| REQID | Unique identifier (for CANCEL) |
| NOCHECK | Do not verify that TRANSID is defined |
| RESP | Capture response code |
If TERMID is not specified, the transaction starts as a detached (non-terminal) task — it has no terminal, cannot issue SEND/RECEIVE, and typically writes output to a TD queue.
EXEC CICS RETRIEVE: Receiving Data in a STARTed Transaction
When a transaction is started by EXEC CICS START with FROM/LENGTH, the started transaction uses RETRIEVE to get the passed data:
*── RTRY transaction: started by EXEC CICS START ─────────────────
IDENTIFICATION DIVISION.
PROGRAM-ID. RTRYPGM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-RETRY-DATA.
05 WS-RD-KEY PIC X(6).
05 WS-RD-RETRY-NO PIC 9(2).
01 WS-DATA-LEN PIC S9(4) COMP VALUE +8.
01 WS-RESP PIC S9(8) COMP VALUE ZERO.
PROCEDURE DIVISION.
MAIN-LOGIC.
*── Retrieve data passed by the initiating START ─────────────
EXEC CICS RETRIEVE
INTO(WS-RETRY-DATA)
LENGTH(WS-DATA-LEN)
RESP(WS-RESP)
END-EXEC
EVALUATE WS-RESP
WHEN DFHRESP(NORMAL)
PERFORM PROCESS-RETRY
WHEN DFHRESP(NOTFND)
*> No data was passed — unexpected
PERFORM LOG-ERROR
WHEN OTHER
PERFORM HANDLE-ERROR
END-EVALUATE
EXEC CICS RETURN END-EXEC.
PROCESS-RETRY.
*── Attempt the operation again ──────────────────────────────
EXEC CICS READ FILE('EMPFILE')
RIDFLD(WS-RD-KEY)
INTO(WS-EMP-REC)
RESP(WS-RESP)
END-EXEC
IF WS-RESP = DFHRESP(NORMAL)
PERFORM UPDATE-EMPLOYEE
ELSE IF WS-RD-RETRY-NO < 3
*> Schedule another retry ─────────────────────────────────
ADD 1 TO WS-RD-RETRY-NO
EXEC CICS START TRANSID('RTRY')
AFTER HOURS(0) MINUTES(1) SECONDS(0)
FROM(WS-RETRY-DATA)
LENGTH(LENGTH OF WS-RETRY-DATA)
END-EXEC
ELSE
*> Max retries reached — log failure ─────────────────────
PERFORM LOG-RETRY-FAILURE
END-IF.EXEC CICS CANCEL: Cancelling a Pending START
If a scheduled transaction is no longer needed, CANCEL removes it from the CICS timer queue before it fires:
*── Cancel a pending retry if the user cancels the transaction ───
CANCEL-PENDING-RETRY.
EXEC CICS CANCEL REQID(WS-REQID)
TRANSID('RTRY')
RESP(WS-RESP)
END-EXEC
*── NOTFND is acceptable — already fired or never existed ────
IF WS-RESP NOT = DFHRESP(NORMAL)
AND WS-RESP NOT = DFHRESP(NOTFND)
PERFORM LOG-CANCEL-ERROR
END-IF.The REQID must match the value that was specified on the original START command. For this reason, always specify a meaningful, unique REQID when using START if there is any chance you will need to CANCEL it.
Practical Patterns Using Interval Control
Pattern 1: Timeout Handler
*── Start a timeout monitor that fires if no response in 60 seconds ─
START-TIMEOUT-MONITOR.
STRING 'TOUT' EIBTRMID DELIMITED SIZE INTO WS-TIMEOUT-REQID
EXEC CICS START TRANSID('TOUT')
AFTER HOURS(0) MINUTES(1) SECONDS(0)
TERMID(EIBTRMID)
REQID(WS-TIMEOUT-REQID)
END-EXEC.
*── When response arrives, cancel the timeout ────────────────────
CANCEL-TIMEOUT.
EXEC CICS CANCEL REQID(WS-TIMEOUT-REQID)
TRANSID('TOUT')
RESP(WS-RESP)
END-EXEC.Pattern 2: Polling Loop with START
*── Poll for a file every 5 minutes ─────────────────────────────
CHECK-AND-RESCHEDULE.
PERFORM CHECK-INPUT-FILE
IF NOT WS-FILE-READY
EXEC CICS START TRANSID(EIBTRNID)
AFTER HOURS(0) MINUTES(5) SECONDS(0)
END-EXEC
ELSE
PERFORM PROCESS-INPUT-FILE
END-IF
EXEC CICS RETURN END-EXEC.Key Takeaways
CICS Interval Control gives you time-aware transaction management. ASKTIME and FORMATTIME handle date/time capture and formatting. DELAY suspends a task (use sparingly — it holds resources). START schedules a new transaction at a specific clock time or after an interval, optionally passing data via FROM/RETRIEVE. CANCEL removes a pending scheduled start. Together, these commands enable retry logic, polling, timeout handling, and scheduled batch initiation from online CICS transactions — without requiring a separate z/OS scheduler or JCL.
For understanding how CICS connects to DB2 and executes SQL, continue with CICS and DB2 Integration. For the complete CICS course, visit the CICS Mastery Course.
