DC allows you to obtain the current time and date from the operating system. You can use these values either for screen display or for journaling purposes.
For more information on journaling, see Writing to the Journal File.
To obtain the current time and date, issue a GET TIME statement that specifies the variable-storage location into which DC is to return the current time and, optionally, the current date.
Example of Obtaining the Current Time and Date
The program excerpt below obtains the time and date for display on the terminal screen.
It obtains the current time in edit format (hh:mm:ss:hhh) and the current date in fixed binary format. You must change the date to display format in order to display it on the terminal screen.
DATA DIVISION. WORKING-STORAGE SECTION. 01 DEPTDISM PIC X(8) VALUE 'DEPTDISM'. 01 SOLICIT-REC. 05 SOLICIT-DEPT-ID PIC X(4). 05 TASK-INFO. 07 TC PIC X(8). 88 GETOUT VALUE 'DEPTBYE'. 07 LTERMINAL PIC X(8). 07 PTERMINAL PIC X(8). 07 CURR-USER PIC X(32). 07 CURR-TIME PIC X(11). 07 SYS-DATE PIC 9(7) COMP-3. 07 CURR-DATE PIC 9(5). PROCEDURE DIVISION. ACCEPT TASK CODE INTO TC. IF GETOUT DC RETURN. BIND MAP SOLICIT. BIND MAP SOLICIT RECORD SOLICIT-REC. * ACCEPT LTERM ID INTO LTERMINAL. ACCEPT PTERM ID INTO PTERMINAL. ACCEPT USER ID INTO CURR-USER. *** GET THE CURRENT TIME AND DATE *** GET TIME INTO CURR-TIME EDIT DATE INTO SYS-DATE. *** CHANGE THE DATE TO DISPLAY FORMAT *** MOVE SYS-DATE TO CURR-DATE. MOVE ZERO TO SOLICIT-DEPT-ID. MAP OUT USING SOLICIT NEWPAGE MESSAGE IS INITIAL-MESSAGE LENGTH 80. * DC RETURN NEXT TASK CODE DEPTDISM.
Example of Displaying Current Time and Date
The mapout in the program excerpt results in this screen display:
LTERM: LT12002 PTERM: PV12002 USER: RKN *** DEPARTMENT SOLICITOR SCREEN *** TIME: 11:49:45.60 DATE: 86.037 DEPARTMENT ID: 0000 ENTER AN DEPT ID AND PRESS ENTER ** CLEAR TO EXIT
Copyright © 2013 CA.
All rights reserved.
|
|