Sign in

docs ILE Concepts

Program Creation Example 2

Program Creation Example 2

Program Creation Example 2

Figure 1 shows the result of a similar CRTPGM request, except that the service program on the BNDSRVPGM parameter has been removed:

CRTPGM  PGM(TEST/A)
        MODULE(*LIBL/M1)
        BNDDIR(*LIBL/L)
        OPTION(*DUPPROC)

Figure 1. Symbol Resolution and Program Creation: Example 2

Symbol Resolution and Program Creation: Example 2

The change in ordering of the objects to be processed changes the ordering of the exports. It also results in the creation of a program that is different from the program created in example 1. Because service program S is not specified on the BNDSRVPGM parameter of the CRTPGM command, the binding directory is processed. Module M2 exports procedure P20 and is specified in the binding directory ahead of service program S. Therefore, module M2 gets copied to the resulting program object in this example. When you compare Figure 1 with Figure 1 you see the following:

  • Program A in example 1 contains only module M1 and uses procedures from service programs S, T, and QLEPRINTS.
  • In program A of example 2, two modules called M1 and M2 use service programs T and QLEPRINTS.

The program in example 2 is created as follows:

  1. The first parameter (PGM) specifies the name of the program to be created.
  2. The value specified on the second parameter (MODULE) is M1, so the binder again starts there. Module M1 contains the same three imports that need to be resolved: P20, P21, and Prints.
  3. This time, the third parameter specified is not BNDSRVPGM. It is BNDDIR. Therefore, the binder first scans the binding directory specified (L).
    1. The first entry specified in the binding directory is module M1. Module M1 from this library was already processed by the module parameter.
    2. The second entry specified in the binding directory is for module M2. The binder scans the export list of module M2. Because that export list contains P20, that import request is resolved. Module M2 is bound by copy and its imports must be added to the list of unresolved import requests for processing. The unresolved import requests are now P21, Prints, and P30.
    3. Processing continues to the next object that is specified in the binding directory, the ‘S’ service program. Here, the service program S provides the P30 export for currently unresolved import requests of P21 and Prints. Processing continues to the next object that is listed in the binding directory, service program T.
    4. Service program T provides export P21 for the unresolved import.
  4. As in example 1, import request Prints is not specified. However, the procedure is found in the runtime routines provided by the language in which module M1 was written.

Symbol resolution is also affected by the strength of the exports. For information about strong and weak exports, see Export in Import and Export Concepts.