COBOL: Static Vs Dynamic Call Which is Better

Static call Vs. Dynamic call, and which is better? The answer is it depends. Precisely, a Static call is faster and takes less CPU time since the load module sits with the main program’s load module.

However, the Dynamic call is slower and takes more CPU time since the load module is separately stored and takes extra time to place with the main module.

1. The Static Vs. Dynamic call differences

Cobol Static and dynamic calls
Static vs Dynamic call differences

2. Example for static call

PROCEDURE DIVISION.
CALL "SUBPROG" USING RECORD-1.
CALL "PAYMASTR" USING RECORD-1 RECORD-2.
STOP RUN.

Advertisements

3. Example for dynamic call

PROCEDURE DIVISION.
. . .
MOVE "SUBPROG" TO PGM-NAME.
CALL PGM-NAME USING RECORD-1.
CANCEL PGM-NAME.
MOVE "PAYMASTR" TO PGM-NAME.
CALL PGM-NAME USING RECORD-1 RECORD-2.
STOP RUN.
 Usage of Entry
PROCEDURE DIVISION USING PAYREC.
. . .
EXIT PROGRAM.
ENTRY "PAYMASTR" USING PAYREC PAY-CODE.  
<<<<<< This shows how one subprogram 
calls another program >>>>
    . . .
GOBACK.

2. Compiler options: DYNAM and NODYNAM

DYNAM

The DYNAM option applies to dynamic calls and is not for static calls.

NODYNAM

The NODYNAM applies to both static and dynamic calls.

References

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.