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. Use either CALL
literal or CALL identifier statements to make
calls to nested programs.
You can call a nested
program only from its directly containing program unless you identify the
nested program as COMMON in its PROGRAM-ID paragraph. In
that case, you can call the common program from any program that is
nested (directly or indirectly) in the same program as the common program.
Only nested programs can be identified as COMMON. Recursive calls are
not allowed.
Follow
these guidelines when using nested program structures:
- Code an IDENTIFICATION DIVISION in each program. All other
divisions are optional.
- Optionally make the name of each nested program unique. Although
the names of nested 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 nested
program.
- In the outermost program, code any CONFIGURATION SECTION entries
that might be required. Nested programs cannot have a CONFIGURATION
SECTION.
- Include each nested program in the containing program immediately before
the END PROGRAM marker of the containing program.
- Use an END PROGRAM marker to terminate nested and containing
programs.
- The linkage that is generated for nested programs
is always OPTLINK. If you are calling a nested program using a CALL
identifier statement, ensure that the OPTLINK linkage convention
is used for that CALL statement by specifying the CALLINT(OPTLINK)
compiler option or the >>CALLINT OPTLINK compiler
directive.
related concepts
Nested programs
related references
Scope of names
OPTLINK
CALLINT
|