Program Creation Example 1
Program Creation Example 1
Program Creation Example 1
Assume that the following command is used to create program A in Figure 1:
CRTPGM PGM(TEST/A)
MODULE(*LIBL/M1)
BNDSRVPGM(*LIBL/S)
BNDDIR(*LIBL/L)
OPTION(*DUPPROC)
Figure 1. Symbol Resolution and Program Creation: Example 1

To create program A, the binder processes objects specified on the CRTPGM command parameters in the order specified:
- The value specified on the first parameter (PGM) is A, which is the name of the program to be created.
- The value specified on the second parameter (module) is M1. The binder starts there. Module M1 contains three imports that need to be resolved: P20, P21, and Prints.
- The value specified on the third parameter (BNDSRVPGM) is S. The binder scans the export list of service program S for any procedures that resolve any unresolved import requests. Because the export list contains procedure P20, that import request is resolved.
- The value specified on the fourth parameter (BNDDIR) is L. The
binder next scans binding directory L.
- The first object specified in the binding directory is module M1. Module M1 is currently known because it was specified on the module parameter, but it does not provide any exports.
- The second object specified in the binding directory is module M2. Module M2 provides exports, but none of them match any currently unresolved import requests (P21 and Prints).
- The third object specified in the binding directory is service program S. Service program S was already processed in step 3 and does not provide any additional exports.
- The fourth object specified in the binding directory is service program T. The binder scans the export list of service program T. Procedure P21 is found, which resolves that import request.
- The final import that needs to be resolved (Prints) is not specified on any parameter. Nevertheless, the binder finds the Prints procedure in the export list of service program QLEPRINTS, which is a common runtime routine provided by the compiler in this example. When compiling a module, the compiler specifies as the default the binding directory containing its own runtime service programs and the ILE runtime service programs. That is how the binder knows that it should look for any remaining unresolved references in the runtime service programs provided by the compiler. If, after the binder looks in the runtime service programs, there are references that cannot be resolved, the bind normally fails. However, if you specify OPTION(*UNRSLVREF) on the create command, the program is created.