Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Programming Guide


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.

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 load module, 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 load module name or load module alias of the load module that contains the program.

Each subprogram that you call with a dynamic CALL statement can be part of a different load module 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 hierarchical 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:

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:

Examples: static and dynamic CALL statements

related references  
DLL  
DYNAM  
ENTRY statement (Enterprise COBOL Language Reference)  
CALL statement (Enterprise COBOL Language Reference)  
Language Environment Programming Reference


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)