Compiling multiple programs (batch compilation)

You can compile a sequence of separate COBOL programs by using a single invocation of the compiler. You can link the object program produced from this compilation into one program object or separate program objects, controlled by the NAME compiler option.

When you compile several programs as part of a batch job, you need to:

  • Determine whether you want to create one or more program objects.
  • Terminate each program in the sequence.
  • Specify compiler options, with an awareness of the effect of compiler options specified in programs within the batch job.

To create separate program objects, precede each set of objects with the NAME compiler option. When the compiler encounters the NAME option, the first program in the sequence and all subsequent programs until the next NAME compiler option is encountered are link-edited into a single program object. Then each successive program that is compiled with the NAME option is included in a separate program object.

Use the END PROGRAM marker to terminate each program in the sequence except the last program in the batch (for which the END PROGRAM marker is optional). Alternatively, you can precede each program in the sequence with a CBL or PROCESS statement.

If you omit the END PROGRAM marker from a program (other than the last program in a sequence of separate programs), the next program in the sequence will be nested in the preceding program. An error can occur in either of the following situations:

  • A PROCESS statement is in a program that is now nested.
  • A CBL statement is not coded entirely in the sequence number area (columns 1 through 6).

    If a CBL statement is coded entirely in the sequence number area (columns 1 through 6), no error message is issued for the CBL statement because it is considered a label for the source statement line.

Example: batch compilation

related references  
NAME