You are on page 1of 2

what is the difference between static call and dyn...

Static calls refer to calls made to subprograms that was link-edited to the main program at
compile time. That is the subprogram's object code is part of the main programs object code.
This is established on compile time with the NODYNAM compiler option.Dynamic calls refer to
calls made to programs with separate object code from the main program. This is established
on compile time with the DYNAM compiler option.Subprogram called in STATIC mode will
always contain values from previous calls if the INITIAL keyword was not coded in the Program-
ID declaration in the subprogram's IDENTIFICATION DIVISION. But you can reset the values by
coding CANCEL from the main program.Subprogram called in DYNAMIC mode will always be in
initial state.Hope this helps.

in the case of static call the mainprogram and subpgms r loaded into the mainmemory
initially.in the case of dynamic call only the mainpgm is loaded first and the subpgm is loaded
only when a call to it is made.so the memory utilization is good in dynamic call.

Static CALLs
In COBOL, you normally call a subroutine like this:

CALL 'A' USING arguments

The static form of the CALL statement specifies the name of the subroutine as a literal; e.g., it
is in quotes.

This is the static form of a subroutine call. The compiler generates object code for this which
will cause the linker to copy the object module a.obj into your executable when it is linked.

So, if you modify "A" and recompile it, you must also relink all of the executables that call "A",
because the each of the executables contains its own copy of "A".

Dynamic CALLs
In COBOL, the dynamic form of a subroutine call is coded like this:

01 SUBROUTINE-A PIC X(8) VALUE 'A'.


CALL SUBROUTINE-A USING arguments

The dynamic form of the CALL statement specifies the name of the subroutine using a variable;
the variable contains the name of the subroutine to be invoked.

The difference is that the name of the subroutine is found in the variable SUBROUTINE-A. The
compiled code will cause the operating system to load the subroutine when it is required
instead of incorporating it into the executable..

Static Call:
1. in COBOL if you Code a call statement as fooliows is a static call.
CALL 'Pgm1' Using Var1 Var2 ...
2. Compiler option for Static call is NODYNAM
3. Calling Program and Called program loads are available in same loadmoduale.
4. It occupies more Real memory due to all loadmodules are available in real memory.
5. Processing will be Fast due to all programs loads are available in memory.

Dynamic Call:
2. If you write a Call statement by using Call leterals this type of call is called as Dynamic call
as follows.
CALL WS-PGM1 Using Var1 Var2 ...
2. Compiler Option for Dynamic call is DYNAM.
3. Called program and calling program will be available in separate loads.
4. On Execution Program will occupy less memory due to only active program load will be
loaded in the real memory.
5. Processing speed will be slow compare with Static call. because main program calling
Subprogram then main program will be replaced with subprogram in the memory and once sub
program finishes execution again main program will be loaded so loading and unloading will
decrease speed of execution.