The DB2 ECM supports nested COBOL programs and PL/I external routines, but in some cases requires specification of an additional DB2 compiler directive option.
For non-nested COBOL programs, the DB2 ECM generates DB2 interface code in the form of a BND file that is then bound into a DB2 LUW package. The base name of both the BND and the package file defaults to the base name of the source file. You can override the base name using the PACKAGE directive to specify an alternative name. See PACKAGE for details.
For nested programs, you can use one of the following DB2 ECM directives to define how DB2 interface code is generated for a single source file. These directives are mutually exclusive, meaning you can specify only one at a time for any given source file:
The names generated for BND files and packages can differ depending on whether or not you also specify the PACKAGE directive with a parameter in addition to MULTI_PACKAGE.
Example 1: Compile DEMO.cbl with MULTI_PACKAGE
The names of generated BND and package files are based on the program ID of each nested program, and the BND file and package names for the main program are based on the base name of the source file as follows:
Program ID | Resulting BND file name | Resulting PACKAGE name |
---|---|---|
MAIN | DEMO | DEMO |
SUB1 | SUB1 | SUB1 |
SUB2 | SUB2 | SUB2 |
Example 2: Compile DEMO.cbl with MULTI_PACKAGE and PACKAGE=TEST
The BND file and package names are modified to include the package name as follows:
Program ID | Resulting BND file name | Resulting PACKAGE name |
---|---|---|
MAIN | DEMO | TEST |
SUB1 | TESTSUB1 | TESTSUB1 |
SUB2 | TESTSUB2 | TESTSUB2 |
See MULTI_PACKAGE for additional details on using this directive.
If more than one nested program using EXEC SQL statements exists in the source file, you can specify IGNORE-NESTED with a program ID that, when encountered by the DB2 ECM, triggers the generation of DB2 interface code for that program only. The base name of the generated BND and package files is the same as the specified program ID.
If more than one nested program using EXEC SQL statements exists in the source file, and you specify IGNORE-NESTED without a program ID, the DB2 ECM locates the program with a program ID that matches the base name of the source file. In this case, The base name of the generated BND and package files is the same as base name of the source file.
See IGNORE-NESTED for details on using this directive.
Directive | Synonym |
---|---|
PACKAGE | ACCESS |
SINGLE_PACKAGE | MULTI-NESTED |
MULTI_PACKAGE | ALLOW-NESTED |