Sunday, November 20, 2011

NESTED PROGRAMS, GLOBAL, EXTERNAL


One program may contain other program(s). The contained program(s) may themselves contain yet other program(s).  All the contained and containing programs should end with END PROGRAM statement. PGMB is nested a program in the example below:
Example:        IDENTIFICATION DIVISION.
                    PROGRAM-ID. PGMA
                     …
                   IDENTIFICATION DIVISION.
                   PROGRAM-ID. PGMB
                   …
                   END PROGRAM PGMB.
                   …
                   END PROGRAM PGMA.

If you want access any working storage variable of PGMA in PGMB, then declare them with the clause ‘IS GLOBAL’ in PGMA. If you want to access any working storage variable of PGMB in PGMA, declare them with the clause ‘IS EXTERNAL’ in PGMB. Nested Programs are supported only in COBOL85.
If there is a program PGMC inside PGMB, it cannot be called from PGMA unless it’s program id is qualified with keyword COMMON. 

No comments:

Post a Comment