Rational Developer for System z
COBOL for Windows, Version 7.5, Language Reference


Nested programs

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.

In the following code fragment, program Outer-program directly contains program Inner-1. Program Inner-1 directly contains program Inner-1a, and Outer-program indirectly contains Inner-1a:

Id division.
Program-id. Outer-program.
  Procedure division.
    Call “Inner-1”.
    Stop run.
Id division.
  Program-id. Inner-1
  ...
    Call Inner-1a.
    Stop run.
  Id division.
  Program-id. Inner-1a.
  ...
  End Inner-1a.
  End Inner-1.
End Outer-program.

The following figure describes a more complex nested program structure with directly and indirectly contained programs.

Begin description. This figure illustrates a nested program structure similar to that shown in the code above. This figure shows the same concepts with more programs. End description.

Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)