A date with CICS
Putting a CICS application together and you need date and time information? Try the ASKTIME and FORMATTIME commands. This tip explores how they are used.
This tip is based on "Murach's CICS for the COBOL Programmer." If you would like to purchase a copy of the book, click here.
So you are putting a CICS application together and you need date information. You use the EIBDATE and the EIBTIME fields in the Execute Interface Block, right? Yes and no. Those fields return the date and time information from when the task was started which is usually the same as the current time but not necessarily.
You would be better off using the ASKTIME and FORMATTIME commands. This tip will examine exactly how to use those commands. First, let's define what the commands actually do. The ASKTIME command is used to get an absolute time, the number of miliseconds since January 1, 1900. For example, 2:24 p.m. on Feb. 1, 2001 would be +003190026294970. When it is run, the date and time in EIBDATE and EIBTIME fields are updated. You can designate the date and time to be stored in a field you name by using the ABSTIME option.
The FORMATTIME command is used to format the date and time. It can be used to render the date in a variety of ways. For example, you can have it month-date-year or year-day. You can use it to get the number days represented by the absolute time (DAYCOUNT), the day of the week (DATEOFWEEK) or the day of the month (DATEOFMONTH).
Using the ASKTIME command
Here is the syntax for the command:
EXEC CICS
ASKTIME [ABSTIME (date-name]
END EXEC
This is the code to retrieve the absolute time
WORKING-STORAGE-SECTION.
.
.
01 DATE-AND-TIME-FIELDS.
05 ABSOLUTE-TIME PIC S9(15) COMP-3.
.
.
PROCEDURE DIVISION.
.
.
EXEC CICS
ASKTIME ABSTIME(ABSOLUTE-TIME)
END-EXEC.
.
.
Using the FORMATTIME command
Here is the syntax of the command:
EXEC CIS
FORMATTING ABSTIME (data-name)
[DATE(date-name)]
[FULLDATE(date-name)]
[MMDDYYYY(date-name)]
[DDMMYYYY(date-name)]
[YYYYMMDD(date-name)]
[YYYYDDMM(date-name)]
[YYYYDDD(date-name)]
[DATESEP[(date-name | literal)]
[DATEFORM(date-name)]
[DAYCOUNT(date-name)]
[DAYOFWEEK(date-name)]
[DAYOFMONTH(date-name)]
[MONTHOFYEAR(date-name)]
[YEAR(date-name)]
[TIME(date-name) [TIMESEP[(data-name | literal)]]]
END-EXEC