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 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.

Related concepts  
Nested programs

Related references  
Scope of names