ILE C/C++ Programmer's Guide

Handling Unresolved Import Requests by Changing Program Creation Order

You can also change the order of program creation to avoid unresolved references, by first creating a service program with all modules, and then re-creating this same service program later.

  1. To generate binder language for modules M2 and M3, from which you want to create service program SP1, issue the following command:
    RTVBNDSRC MODULE(MYLIB/M2 MYLIB/M3) SRCFILE(MYLIB/QSRVSRC)
       SRCMBR(BNDLANG3)
    

    This command results in the binder language shown in Figure 20 being created in library MYLIB, source file QSRVSRC, file member BNDLANG3.

  2. To create service program SP1 from module M2 and module M3 enter:
    CRTSRVPGM SRVPGM(MYLIB/SP1) MODULE(MYLIB/M2 MYLIB/M3)
    	SRCFILE(MYLIB/QSRVSRC) SRCMBR(BNDLANG3)
     
    

    Because modules M2 and M3 are specified, all import requests are resolved and service program SP1 is created successfully.

  3. To create service program SP2, enter:
    CRTSRVPGM SRVPGM(MYLIB/SP2) MODULE(MYLIB/M3)
    	SRCFILE(MYLIB/QSRVSRC) SRCMBR(BNDLANG2)
    	BNDSRVPGM(MYLIB/SP1)
    

    Because service program SP1 exists, the binder resolves all the import requests required and service program SP2 is created successfully.

  4. To re-create service program SP1, enter:
    CRTSRVPGM SRVPGM(MYLIB/SP1) MODULE(MYLIB/M2)
    	SRCFILE(MYLIB/QSRVSRC) SRCMBR(BNDLANG1)
    	BNDSRVPGM(MYLIB/SP2)
    

    Although service program SP1 does exist, the import request for func2() is not resolved to the one in service program SP2. Therefore, a re-creation of service program SP1 is necessary to make the circular reference work.

    Because service program SP2 now exists, the binder can resolve the import request for func2() from service program SP2, and service program SP1 is successfully created.

  5. To create program A, enter:
    CRTPGM PGM(MYLIB/A) MODULE(MYLIB/M1) BNDSRVPGM(MYLIB/SP1 MYLIB/SP2)
    

    Because service programs SP1 and SP2 do exist, the binder creates program A.

Figure 20. Binder Language for Service Program SP1


+--------------------------------------------------------------------------------+
|  Columns . . . :    1  71           Browse                       MYLIB/QSRVSRC |
| SEU==>                                                                BNDLANG3 |
| FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7  |
|        *************** Beginning of data ************************************  |
|0000.01 STRPGMEXP PGMLVL(*CURRENT)                                              |
|0000.02 /********************************************************************/  |
|0000.03 /*   *MODULE      M2           MYLIB        95/06/11  18:50:23      */  |
|0000.04 /********************************************************************/  |
|0000.05   EXPORT SYMBOL("func1__Fi")                                            |
|0000.06 /********************************************************************/  |
|0000.07 /*   *MODULE      M3           MYLIB        95/06/11  18:50:23      */  |
|0000.08 /********************************************************************/  |
|0000.09   EXPORT SYMBOL("func2__Fi")                                            |
|0000.10 ENDPGMEXP                                                               |
|        ****************** End of data **************************************   |
|                                                                                |
+--------------------------------------------------------------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents ]