COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Putting an Object File on the Primary Search List
If a CALL or ENTER statement does not contain a mnemonic name that specifies the object file that
contains the called program, the compiler searches for the called routine in the object files on the
primary search list. If the compiler finds the routine, it validates the routine’s actual parameters
and includes the entire object file (from the primary search list) in the object file that it is creating.
You can put one or more object files on the primary search list with one or more SEARCH directives.
The first SEARCH directive establishes the primary search list and adds files to it in the specified
order. Subsequent SEARCH directives append files to the primary search list in the specified order.
The compiler searches the object files of the primary search list in order. If the compiler finds the
routine, it stops searching for it.
If you put a SEARCH directive on the compilation command line when you compile your program,
the compiler sees that SEARCH directive first, so the primary search list begins with that SEARCH
directive’s object files.
Putting an Object File on the Tertiary Search List
If the compiler does not find an external routine in the user library, it searches for the routine in
the object libraries on the tertiary search list. If the compiler finds the routine in a library on the
tertiary search list, it validates the routine’s actual parameters but does not include the routine in
your object file. The system loader resolves the routine at fixup.
You can put one or more object libraries on the tertiary search list with one or more CONSULT
directives. The first CONSULT directive establishes the tertiary search list, adding files to it in the
specified order. Subsequent CONSULT directives append libraries to the tertiary search list in the
specified order. The compiler searches the libraries of the tertiary search list in order. If the compiler
finds the routine, it stops searching for it. Object libraries on the tertiary search list are not bound
into the loadfile.
Suppose that the files RTNS1985 and RTNS1988 contain object code for external routines that
your HP COBOL program calls, and that most of the external routines that your program calls are
in RTNS1988. For greatest efficiency, put RTNS1988 first on the tertiary search list. You can use
the directive:
?CONSULT RTNS1988,RTNS1985
You could also use multiple CONSULT directives, which can be anywhere in your HP COBOL
program. This code produces the same tertiary search list as the preceding directive:
?CONSULT RTNS1988
?CONSULT RTNS1985
If you also put a CONSULT directive on the compilation command line when you compile your
program, the compiler sees it first, so the tertiary search list begins with the object libraries in the
CONSULT directive on the compilation command line.
If the compiler does not find the routine in any object file on the tertiary search list, it searches for
the routine in the file ECOBEXT, ZCOBDLL, or ZCREDLL. If the ECOBOL compiler does not find the
routine in ECOBEXT, ZCOBDLL, or ZCREDLL, the compiler reports an error.
Linking Programs to Be Called Dynamically
A dynamic call is one in which the name of the called program is not known until run time (see
Dynamic Calls (page 797)). Every program that a dynamic call could possibly call must be bound
into the run unit or user library before you execute the program. There are several ways to do this:
Compile all the programs in the run unit from a single source file.
Use the linker to build the required program units into the run unit.
Refer to each possible called program explicitly in the source program—in a paragraph that
is not executed—and then call the ones you want with CALL identifier statements.
818 Issues Related to Linking