Static call and dynamic call which is best?. The answer is it depends.
Static call is faster, it takes less CPU time since load is part of main program load module.
Dynamic call is slower, it takes more CPU time since the load module is separately stored, and it takes time to join main program load module
The following chart says key differences between these two.
Important points are- Compiler options DYNAM and NODYNAM.:
DYNAM- If we give this compiler option, we need to give only dynamic calls, and no static calls in COBOL program.
NODYNAM – If we give this compiler option, we can give both static and dynamic calls in the COBOL program.
Example Static Call:
CALL “SUBPROG” USING RECORD-1.
CALL “PAYMASTR” USING RECORD-1 RECORD-2.
Example Dynamic Call:
. . .
MOVE “SUBPROG” TO PGM-NAME.
CALL PGM-NAME USING RECORD-1.
MOVE “PAYMASTR” TO PGM-NAME.
CALL PGM-NAME USING RECORD-1 RECORD-2.
Usage of Entry
PROCEDURE DIVISION USING PAYREC.
. . .
ENTRY “PAYMASTR” USING PAYREC PAY-CODE.
<<<<<< This shows how one subprogram calls another program >>>>
. . .