DavidatK Active Member Joined: 22 Nov 2005 Location: Troy, Michigan USA Posted: Sat Jan 28, 2006 1:12 am Post subject: Re: static and dynamic call in cobol Tarunflash, This subject has been addressed many times in the forums; if you do a search you will find much discussion on the subject. In the most basic terms, a static call to a subroutine is when the subroutine has been included in the executable load module when you link edited it. This is done for a couple of reasons. One is efficiency; the operating system does not have to find and load the subroutine from the system libraries the first time you call it. This also makes you?re program more portable. The downside of static calls is that if there is an updated version of the subroutine available you must re-link your program to pick it up. Whereas, a dynamic call to a subroutine is where the subroutine is NOT included in the executable load module when you link edited it.
The operating system must find and load the subroutine the first time you call it. This means that you can pick up any new versions of the subroutine without re-linking your program. The downside of dynamic calls is that if there is an updated version of the subroutine available you will pick it up, and if there was a change in the subroutine that required you to modify your program you?re program will probably fail. And as the portability is an asset to a static call, it can be a deficit to a dynamic call because the subroutine must be in one of the system libraries and many times you are not 100% sure of the version that is being executed.
In our shop, we are making an effort to use dynamic calls, where updates and fixes to the subroutines are automatically picked up. As for not knowing the version of the subroutine running, we have incorporated a first time switch in the subroutines and display the compile date/time only the first time the subroutine is called. When you call the subroutine it is generally considered a static call if the subroutine name is contained in quotes: Code: CALL?SUBR01? And, if the subroutine name is contained in a variable it is generally considered to be dynamic. Code: 05 SUBROUTINE-NAME PIC X(8) VALUE?SUBR01? CALL SUBROUTINE-NAME USING.
However, either of these can be overridden, You can specify in the compiler that ALL subroutine calls are to be dynamic, even if contained in quotes, and/or you can specifically include the subroutines in the load module at link edit time that makes them static calls. If this is not clear, please let me know Dave:::: - All times are GMT + 6 Hours Page 1 of 1 Search our Forum.
Static Call: 1. In COBOL if you Code a call statement as fooliows is a static call. CALL 'Pgm1' Using Var1, Var2. Microsoft Windows. Compiler option for Static call is NODYNAM 3.
Call Statement In Cobol
Calling Program and Called program loads are available in same loadmoduale. It occupies more Real memory due to all loadmodules are available in real memory. 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. Hp probook. Compiler Option for Dynamic call is DYNAM.
Called program and calling program will be available in separate loads. On Execution Program will occupy less memory due to only active program load will be loaded in the real memory.
The 1973 annual handbook for group facilitators. Contents: Structures experiences. Find more information about: ISBN: 819 OCLC Number: 9160197 Description: viii, 292 pages: illustrations; 22 cm.
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.
Static And Dynamic Call In Cobol
Here is some information about static and dynamic calls which may help you. 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'.
Static Call
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. 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) the correct compiler options(i.e thru DYNAM option in jcl).