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

In the CALL statement, the called program must be a COBOL program. It can be part of the same
compilation unit as the calling program, or it can be an external reference to a COBOL program
outside the compilation unit (but in the same object file). All ENTER statements cause external
references, because they call programs compiled from source languages other than COBOL.
To generate the proper code to call a separately compiled program, the compiler needs a
description of the parameter list of that program. Each CALL or ENTER statement can include
qualification that specifies where the compiler must find the program. Although the compiler must
search for unqualified programs, qualification significantly restricts the activity of the compiler.
Qualified References
Each CALL or ENTER statement can include a file-mnemonic that identifies the object file where
the linker must look for the called program, resolving the external reference and including the
called program’s object code in the target file. You must associate this file-mnemonic with the
object file’s file-system file name in the SPECIAL-NAMES paragraph in the Environment Division
that governs the calling program. (Either the calling program is not nested, and contains an
Environment Division; or the calling program is nested, and its outermost containing program
contains an Environment Division.)
If the compiler does not find the program in the specified object file, it reports an error and creates
no code or data blocks for the program unit. Example 147 contains three examples of qualified
references.
How the Compiler Resolves Unqualified References
When a program name is not qualified and the program it names is not in the compilation unit
(such as the call to A-FRIEND in Example 147) the compiler resolves the reference in one of these
ways:
If you provided one or more search lists, the compiler examines those files in sequence for
program names that correspond to the external references.
If you did not provide search lists, or if the compiler did not find the necessary external
references on them:
You create primary and tertiary search lists with the SEARCH, LIBRARY, and CONSULT directives,
respectively. (The ECOBOL compiler does not recognize the LIBRARY directive or have a user
library, the secondary search list.) You can also use the predefined SEARCH DEFINEs to specify
one or more subvolumes to be searched for unqualified files (see Predefined SEARCH DEFINEs).
For more information, see:
Primary Search List
Tertiary Search List
ECOBEXT File
ECOBEX0 and ECOBEX1 Files
Primary Search List
SEARCH directives define the primary search list, an ordered list of object files. Each SEARCH
directive adds one or more files to the primary search list. The compiler adds files to the search
list in the order that they appear in the SEARCH directives. When trying to resolve unqualified
external references, the compiler searches the files of the primary search list in the order that they
appear. If the compiler resolves an external reference from the primary search list, the object
program that the compiler finds is bound into the target file.
Tertiary Search List
CONSULT directives define the tertiary search list. Each CONSULT directive adds one or more
files to the tertiary search list. The compiler adds files to the search list in the order that they appear
Compilation Details 517