ACCEPT System Time Example


Scenario - Receiving System Time using ACCEPT.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       IDENTIFICATION DIVISION.
       PROGRAM-ID. ACCPTIME.
       AUTHOR. MTH.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-VAR.
          05 WS-TIME-HHMMSSTT     PIC 9(08).

       PROCEDURE DIVISION.
      * Receiving system time in default format.
           ACCEPT WS-TIME-HHMMSSTT FROM TIME.

           DISPLAY 'TIME HHMMSSTT: ' WS-TIME-HHMMSSTT.

           STOP RUN.

Output -

TIME HHMMSSTT: 06021272

Explaining Example -

In the above example:

  • It accepts the system time in the default format (HHMMSSTT) and stores it in WS-TIME-HHMMSSTT.
  • Then, it displays the time value.