Calling nested COBOL programs
By calling nested programs, you can create applications
that use structured programming techniques. You can also call nested
programs instead of PERFORM procedures to prevent
unintentional modification of data items.
About this task
Use either CALL literal or CALL identifier statements
to make calls to nested programs.
You
can call a contained program
only from its directly containing program unless you identify the contained program as COMMON in
its PROGRAM-ID paragraph. In that case, you can call
the common program from any program that is contained (directly or indirectly)
in the same program as the common program. Only contained programs can be identified
as COMMON. Recursive calls are not allowed.
Follow these guidelines when using nested program structures:
- Code an
IDENTIFICATION DIVISIONin each program. All other divisions are optional. - Optionally make the name of each contained program unique. Although the names of contained programs are not required to be unique (as described in the related reference about scope of names), making the names unique could help make your application more maintainable. You can use any valid user-defined word or an alphanumeric literal as the name of a contained program.
- In the outermost program, code any
CONFIGURATION SECTIONentries that might be required. Contained programs cannot have aCONFIGURATION SECTION. - Include each contained program
in the containing program immediately before the
END PROGRAMmarker of the containing program. - Use an
END PROGRAMmarker to terminate contained and containing programs.
You
cannot use the THREAD option when compiling programs
that contain nested programs.