Cobol- Static Call and Dynamic Call

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.

Cobol Static and dynamic calls
Cobol Static and dynamic calls

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:

PROCEDURE DIVISION.

CALL “SUBPROG” USING RECORD-1.

CALL “PAYMASTR” USING RECORD-1 RECORD-2.

STOP RUN.

Example 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.

References..
Advertisements

Author: Srini

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