Program Shell
Because the individual program segments cannot be compiled separately, the precompiler creates a program shell (.cbl) before it compiles a program. The program shell contains all the individual segments required to compile a program. The precompiler creates the program shell each time it compiles a program to ensure that changes made in any program segment are reflected in the shell.
To create the program shell (.cbl), the precompiler analyzes the program's procedural code (PD) and includes any library modules, database input/output routines, and program files referenced by the program. All program shells contain the following items:
-
The required DIVISION and SECTION statements.
-
Working storage for the transaction code, database, and form routines.
-
Database routines.
-
Form routines.
-
Files specific to the program.
The precompiler copies some routines into the program shell and generates code for other routines, as shown in the following example.
When the PD references a routine in an Application Program Interface (API) library (for example, 500-DATE-COMPARE), the precompiler copies the library (continuing with the previous example, DATERTNS) with that routine into the program shell. If the library just copied requires any specific working storage data definitions (again, continuing with the same example, DATEWS), the compiler also copies the data definition(s) into the program shell.
Some routines, such as database input/output routines, are not stored in libraries. The precompiler generates code for these routines (for example, 840-FIND-EMPSET1) when it builds the program shell. You do not have to write these routines; the precompiler generates them to fit your specific database system environment.
Although the precompiler creates the shell before it compiles the program, you can build a shell without compiling the program. For instructions on compiling a program, see Doc for Developers: Application Development Workbench.
The construction of the program shell and its processing sequence are fixed; you cannot change either of them.