ASKTIME
ASKTIME
The CICS ASKTIME statement retrieves the current date and time from the CICS system clock, storing the date in the EIBDATE field and the time in the EIBTIME field. This command is commonly used for logging, timestamping transactions, calculating time differences, and scheduling events. Since CICS does not automatically provide time details, the ASKTIME statement allows programs to obtain the current date and time as a binary timestamp.
Syntax -
EXEC CICS ASKTIME
ABSTIME(data-area)
[RESP(response-field)]
[RESP2(response-field2)]
END-EXEC.
- ABSTIME(data-area) - Stores the binary format timestamp (milliseconds since 00:00:00 GMT on January 1, 1900). The time is returned as a packed decimal of length 8 bytes. The data-area declaration in COBOL is PIC S9(15) COMP-3.
- RESP(response-variable) - Optional. It captures the response code of the ASKTIME 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 ASKTIME operation when the error occured.
Short Examples -
Scenario - Fetching the System Time Using ASKTIME
...
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-TIMESTAMP PIC S9(15) COMP-3.
01 WS-RESP PIC S9(4) COMP.
PROCEDURE DIVISION.
EXEC CICS ASKTIME
ABSTIME(WS-TIMESTAMP)
RESP(WS-RESP)
END-EXEC.
IF WS-RESP = DFHRESP(NORMAL) THEN
...
ELSE
...
END-IF.
...
The ASKTIME command is executed. The system time is stored in WS-TIMESTAMP in binary format. The response code (RESP) is checked to confirm whether the operation was successful.