Published on

Subprogram

COBOL nested programs and WHEN-COMPILED

IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN.
AUTHOR. T-REXY.
DATE-WRITTEN. 2020-11-11.
DATE-COMPILED. Ask the nested program.
PROCEDURE DIVISION.
  DISPLAY "Start of MAIN program"
  ALL "NESTED" END-CALL
  GOBACK
  .
IDENTIFICATION DIVISION.
PROGRAM-ID. NESTED.
DATA DIVISION.
WORKING-STORAGE SECTION.
  01 WS-WHEN-COMPILED.                                         
    05 WS-COMPILE-DATE  PIC X(8) VALUE 'MM/DD/YY'.
    05 WS-COMPILE-TIME  PIC X(8) VALUE 'HH.MM.SS'.
PROCEDURE DIVISION.
  DISPLAY "Start of NESTED program"
  MOVE WHEN-COMPILED TO WS-WHEN-COMPILED
  DISPLAY "Compiled on " WS-WHEN-COMPILED
  EXIT PROGRAM
  .
END PROGRAM NESTED.
END PROGRAM MAIN.