Importance of the Order of Exports

With only a slight change to the command, you can create a different, but potentially equally valid, program. The order in which objects are specified on the MODULE, BNDSRVPGM, and BNDDIR parameters is usually important only if both of the following are true:
  • Multiple modules or service programs are exporting duplicate symbol names
  • Another module needs to import the symbol name
Most applications do not have duplicate symbols, and programmers seldom need to worry about the order in which the objects are specified. For those applications that have duplicate symbols exported that are also imported, consider the order in which objects are listed on CRTPGM or CRTSRVPGM commands.

The following examples show how symbol resolution works. The modules, service programs, and binding directories in Figure 1 are used for the CRTPGM requests in Figure 1 and Figure 1. Assume that all the identified exports and imports are procedures.

The examples also show the role of binding directories in the program-creation process. Assume that library MYLIB is in the library list for the CRTPGM and CRTSRVPGM commands. The following command creates binding directory L in library MYLIB:
CRTBNDDIR BNDDIR(MYLIB/L)
The following command adds the names of modules M1 and M2 and of service programs S and T to binding directory L:
ADDBNDDIRE BNDDIR(MYLIB/L) OBJ((M1 *MODULE) (M2 *MODULE) (S) (T))
Figure 1. Modules, Service Programs, and Binding Directory
Modules, Service Programs, and Binding Directory