Making dynamic calls
When you use a CALL
literal statement
in a program that is compiled using the DYNAM
and
the NODLL
compiler options, or when you use the CALL
identifier statement
in a program that is compiled using the NODLL
compiler
option, a dynamic call occurs.
About this task
In these forms of the CALL
statement, the called COBOL subprogram is not
link-edited with the main program. Instead, it is link-edited into a separate program object, and is loaded at run time only when it is required (that is, when called). The
program-name in the PROGRAM-ID
paragraph or ENTRY
statement must
be identical to the corresponding program object name or program object alias of the program object that contains the program.
One of the common reasons for messages CEE3593I, CEE3541S, CEE3574I, and IGZ0178S
during dynamic calls is that the program-name
in the PROGRAM-ID
paragraph is not identical to the corresponding program object name or alias.
Each subprogram that you call with a
dynamic CALL
statement can be part of a different program object that is a member of either the system
link library or a private library that you supply. In either case
it must be in an MVS load library;
it cannot reside in the z/OS® UNIX file system.
When a dynamic CALL
statement calls a subprogram
that is not resident in storage, the subprogram is loaded from secondary
storage into the region or partition that contains the main program,
and a branch to the subprogram is performed.
The
first dynamic call to a subprogram within a run unit obtains a fresh
copy of the subprogram. Subsequent calls to the same subprogram (by
either the original caller or any other subprogram within the same
run unit) result in a branch to the same copy of the subprogram in
its last-used state, provided the subprogram does not possess the INITIAL
attribute.
Therefore, the reinitialization of either of the following items is
your responsibility:
GO TO
statements that have been altered- Data items
If you call the same COBOL program in different run units,
a separate copy of WORKING-STORAGE
is allocated for
each run unit.
Restrictions: You cannot make dynamic calls to:
- COBOL DLL programs
- COBOL programs compiled with the
PGMNAME(LONGMIXED)
option, unless the program-name is less than or equal to eight characters in length and is all uppercase - COBOL programs compiled with the
PGMNAME(LONGUPPER)
option, unless the program-name is less than or equal to eight characters in length - More than one entry point in the same COBOL program (unless an
intervening
CANCEL
statement was executed)
Examples: static and dynamic CALL statements
When to use a dynamic call with subprograms
Performance considerations of static and dynamic calls
DLL
DYNAM
ENTRY statement (Enterprise COBOL for z/OS Language Reference)
CALL statement (Enterprise COBOL for z/OS Language Reference)
Language Environment® Programming Reference