Thursday, November 20, 2008

What is Dynamic call in COBOL ?

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. So, if you modify "A" and recompile it, you need not recompile/relink any of the executables that call "A".

NOTE : some compilers let you set options that will override the calling mechanisms shown above. Therefore, even if your program is coded to call a program statically, the compiler can convert it to the dynamic form of CALL if you set (or don't set). We will talk about these options later.

Hope this post made some things crispier. Please do provide your comments or reactions.

What is STATIC call in COBOL?

In COBOL, The static form of the CALL statement specifies the name of the subroutine as a literal:
CALL 'A' USING arguments , where 'A' is exact name of the program which we want to invoke.

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

Hope you gained something from this article. Please do provide your comments or reactions.