COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-24
CALL
Effect of CALL Statement Without PORT Directive
If the object form of the called program is included in the run unit that contains the
calling program, or if the called program is in the user library, execution of the
CALL statement transfers control from the calling program to the called program.
When the called program executes an EXIT PROGRAM statement or allows
control to pass beyond the end of its Procedure Division, control returns to the
calling program. If a NOT ON EXCEPTION phrase (not-on-phrase ) is
specified, control passes to non-excp-imperative-statement and execution
continues according to the rules for that statement. Unless that statement transfers
control elsewhere, control passes from that statement to the end of the CALL
statement.
If the object form of the called program is not included in the run unit, the action of
the CALL statement depends on the presence or absence of an EXCEPTION
phrase (on-phrase or historical-on-phrase ). If an EXCEPTION phrase is
specified, control passes to excp-imperative-statement. If an EXCEPTION
phrase is not specified, the run unit terminates abnormally with a failure message.
Determining Which Program a CALL program-name Statement Calls
The steps for determining which program the CALL statement calls follow.
1. The value of program-name—the program name—is stripped of leading and
trailing spaces and is converted to uppercase. (All COBOL program names are
converted to uppercase for the purpose of matching.)
2. If the program name from Step 1 is that of a COBOL program that was
compiled in this compilation unit, then that program is the called program.
3. If the program name from Step 1 is not that of a program that was compiled in
this compilation unit, then the program searches for a program by that name in
these places, in this order:
a. The file associated with file-mnemonic (if file-mnemonic is
specified)
b. The files on the primary search list (established by the SEARCH directive)
c. The files on the tertiary search list (established by the CONSULT directive)
d. For a TNS program, the TNS user library (established by the LIBRARY
directive)
e. The files associated with SEARCH DEFINEs
4. If the program name from Step 1 is that of a program in one of the preceding
files, that program is the called program.
5. The program name from Step 1 is restored to its original case.
6. Step 3 is repeated.