Static call and dynamic call which is better? 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
1.Static Vs Dynamic Call differences.
2. Compiler options DYNAM and NODYNAM.
This option we need to give only for dynamic calls, and not for static calls.
This option, we can give for both static and dynamic calls.
Example Static Call:
PROCEDURE DIVISION. CALL "SUBPROG" USING RECORD-1. CALL "PAYMASTR" USING RECORD-1 RECORD-2. STOP RUN.
COBOL Search and Search-all When to Use
Explained in simple terms when you need to use these two in your COBOL program.
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.