ACCEPT System Day Example


Scenario - Receiving system day in different formats.

Code -

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

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-VAR.
          05 WS-DAY-YYDDD         PIC 9(05).
          05 WS-DAY-YYYYDDD       PIC 9(07).
		  05 WS-DAY-N             PIC 9(01).

       PROCEDURE DIVISION.
      * Receiving system day in default format. 
           ACCEPT WS-DAY-YYDDD  FROM DAY. 

      * Receiving system day in YYYYDDD.
           ACCEPT WS-DAY-YYYYDDD FROM DAY YYYYDDD.

      * Receiving system day of the Week.        
           ACCEPT WS-DAY-N      FROM DAY-OF-WEEK.
		   
           DISPLAY 'DAY YYDDD   :  ' WS-DAY-YYDDD
           DISPLAY 'DAY YYYYDDD :  ' WS-DAY-YYYYDDD.
           DISPLAY 'DAY DAY-OF-WEEK:   ' WS-DAY-N.		   

           STOP RUN.

Output -

DAY YYDDD   :  24128  
DAY YYYYDDD :  2024128
DAY DAY-OF-WEEK:   2

Explaining Example -

In the above example:

  • It first accepts the system day in the default format (YYDDD) and stores it in WS-DAY-YYDDD.
  • It accepts the system day in the YYYYMMDD format and stores it in WS-DAY-YYYYDDD.
  • It accepts the day of the week as number and stores it in WS-DAY-N.
  • Finally, it displays both day values and terminates the program.