A COBOL program can contain other COBOL programs, which in turn can contain still other COBOL programs. These contained programs are called nested programs. Nested programs can be directly or indirectly contained in the containing program.
A COBOL program may contain other COBOL programs. The contained (or nested) programs may themselves contain yet other programs. A contained program may be directly or indirectly contained within another program. Figure 2 describes a nested program structure with directly and indirectly contained programs.
__________Id Division. X is the outermost program | Program_Id. X. and directly contains X1 and _________>| Procedure Division. X2, and indirectly contains | Display "I'm in X" X11 and X12 | Call "X1" | Call "X2" | Stop Run. | ______Id Division. X1 is directly contained | | Program_Id. X1. in X and directly _________|_>| Procedure Division. contains X11 and X12 | | Display "I'm in X1" | | Call "X11" | | Call "X12" | | Exit Program. | | ___Id Division. X11 is directly | | | Program_Id. X11. contained in X1 ________|__|_>| Procedure Division. and indirectly | | | Display "I'm in X11" contained in X | | | Exit Program. | | |___End Program X11. | | ___Id Division. X12 is directly | | | Program_Id. X12. contained in X1 ________|__|_>| Procedure Division. and indirectly | | | Display "I'm in X12" contained in X | | | Exit Program. | | |___End Program X12. | |______End Program X1. | ______Id Division. | | Program_Id. X2. X2 is directly ___________________|_>| Procedure Division. contained in X | | Display "I'm in X2" | | Exit Program. | |______End Program X2. |_________End Program X.
Figure 2. Nested program structure with directly and indirectly contained programs
Subtopics:
Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.