Static / Dynamic Linking in CICS
In CICS there are three ways of transferring control to a subprogram:
1. Using EXEC CICS LINK Command
2. Using Static COBOL call
3. Using Dynamic COBOL call
The format of the LINK command in the calling program is:
EXEC CICS LINK PROGRAM(‘subpgname’) or EXEC CICS LINK PROGRAM(name)
Link command is always dynamic, irrespective of whether the subprogram name is explicitly given or as a variable with the subprogram name as the value.
Static and dynamic COBOL call is similar to that of normal COBOL programs. The dynamically called subprogram must be defined in the CSD (CICS system definition dataset).
If the called subprogram has CICS commands, then it has be translated by CICS. The CICS translator inserts DFHEIBLK and DFHCOMMAREA into the LINKAGE SECTION and also adds them as the first two parameters in the PROCEDURE DIVISION. In such cases the calling program should use the following syntax:
CALL ‘PROG’ USING DFHEIBLK DFHCOMMAREA PARM1 PARM2 (or)
CALL PROGID USING DFHEIBLK DFHCOMMAREA PARM1 PARM2
The CICS translator forces the compiler options of: RES, RENT, NODYNAM, and LIB which cannot be overridden.
In case of LINK, each time the subprogram is linked to, a new initialized copy of its working storage is provided and the run unit is reinitialized which can cause performance degradation in some cases. In case of dynamic call, the new initialized copy of the working storage is provided on the first entry to the called subprogram. For subsequent calls the same working storage is provided in its last-used state which can result in better performance than the corresponding LINK
The following are the factors to be considered with respect to the application programs:
- Presence of CICS statements in the subprogram would necessitate the use of CICS translator. CICS translator in turn will affect how the program is called (DFHEIBLK & DFHCOMMAREA).
- In case of COBOL call, the subprogram should return control to the calling program either by using GOBACK or EXIT-PROGRAM. In case of LINK, the subprogram should return control to the calling program either by using GOBACK or EXEC CICS RETURN.
- The error condition raised in case of failure in calling the subprogram is different. If the subprogram is unknown/unavailable then LINK fails with PGMIDERR condition. In case of dynamic call, if the subprogram cannot be loaded or not available, then it results in COBOL abend.
- It is understood that in ABACUS, the online programs use dynamic linking and then do a CANCEL after invoking the subprogram. Hence this approach may not have give any performance benefit over the LINK option. Also it is to be noted, to avoid CANCEL (and therefore the re-initialization) the programs should have been coded such that it would not have adverse effect.
More detailed information with sample code refer: http://cicswiki.org/cicswiki1/index.php?title=CALL_vs._LINK#Advantages_of_using_a_LINK.