View previous topic :: View next topic
|
Author |
Message |
prasadrachuri
New User
Joined: 19 Aug 2003 Posts: 20 Location: kolkata
|
|
|
|
Hi,
Can any one explain what is the difference between a STATIC CALL and DYNAMIC CALL.when exactly a module will be said it is called as STATIC or DYNAMIC.
some one say
CALL 'PROG1' USING XXX,YYYY as STATIC
and
CALL 'WS-PROG1' USING XXX,YYYY as DYNAMIC
where WS-PROG1 is working storage variable who's value is 'PROG1'.
and some say
in order to call a module DYNAMIC one should specify DYNAM compiler option should use for program IEWL.but i couldn't found any option like this in my compiler jcl.
Thanks in Advance,
Prasad Rachuri. |
|
Back to top |
|
|
mdtendulkar
Active User
Joined: 29 Jul 2003 Posts: 237 Location: USA
|
|
|
|
Hello prasadrachuri,
DYNAMIC CALL:
Code: |
CALL <prog-name> USING <param1> |
STATIC CALL:
If you are copying any PROCEDURE DIVISION copybook in your program, it is called a STATIC CALL
here program name is a PROCEDURE DIVISION copybook
Hope this helps you
Regards
Mayuresh Tendulkar |
|
Back to top |
|
|
Rajasekhar-Reddy
New User
Joined: 20 Aug 2003 Posts: 1 Location: kolkata
|
|
|
|
Rajasekhar-Reddy wrote: |
Hello prasad,
I think the following matter clear the difference between STATIC CALL AND DYNAMIC CALL
FORM OF CALL MODE
------------------------- --------------
CALL identifier Always dynamic
CALL literal with DYNAM Dynamic
CALL literal with NODYNAM Static
Suppose we have a calling program set up as shown below:
WORKING-STORAGE SECTION.
.
.
01 WS-SUB-PROG PIC X(8) VALUE 'SUBPROG1'.
.
.
01 WS-EMP-REC.
05 WS-EMP-NAME PIC X(20).
05 WS-EMP-ADDR PIC X(20).
05 WS-EMP-SAL PIC S9(5)V99 COMP-3.
.
.
01 WS-PROD-REC.
05 WS-PROD-TYPE PIC X.
05 WS-PROD-UNITS PIC S9(5)V99 COMP-3.
.
.
PROCEDURE DIVISION.
.
.
CALL WS-SUB-PROG USING WS-EMP-REC,
WS-PROD-REC
Since this CALL statement uses an identifier to specify the name of the
subprogram to be called, this would be a dynamic CALL. If the compiler
option NODYNAM is in effect, then a static CALL to the same subprogram
could be coded as:
CALL 'SUBPROG1' USING WS-EMP-REC
WS-PROD-REC
If any thing wrong please let me know...... |
|
|
Back to top |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
Static programs are compiled separately but Linkedited together while dynamic modules are seperately compiled & linkedited. They are identified and loaded into memory at run time by LE or other Run time environments. |
|
Back to top |
|
|
prasadrachuri
New User
Joined: 19 Aug 2003 Posts: 20 Location: kolkata
|
|
|
|
Hi,
Thanks for the repiles...but how can i know is my subprogram is called by STATIC or DYNAMIC by seeing the CALL statement in my program.Can i found any information in my calling program load module.
Thanks in advance,
Prasad Rachuri... |
|
Back to top |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
In your program you need to use a variable name in the call statement for dynamic calls.
ex:
ACCEPT <var1>.
CALL <var1> USING <arg>
At compile time the called program name (var1) is not known. So you need to compile this program with DYNAM option. |
|
Back to top |
|
|
anuradha
Active User
Joined: 06 Jan 2004 Posts: 247 Location: Hyderabad
|
|
|
|
hi prasad,
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'.
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)
REGARDS
ANURADHA |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
I doubt that Prasad is still interested, but for posterity, this is a succinct statemet of the issue:
If compiled as NODYNAM:
CALL 'literal' is a static call
CALL WS-label is a dynamic call
If compiled as DYNAM:
CALL 'literal' is a dynamic call
CALL WS-label is a dynamic call
Regards, Jack. |
|
Back to top |
|
|
Arun Joseph
New User
Joined: 30 Mar 2005 Posts: 13 Location: India
|
|
|
|
Just to add..
The orginal pgms load module will have the load module of a statically called pgm. But not a dynamically called pgm.
So static called pgm has to be compiled before a dynamically called pgm. |
|
Back to top |
|
|
parikshit123
Active User
Joined: 01 Jul 2005 Posts: 269 Location: India
|
|
|
|
Another question related to static v/s dynamic call.
How much expensive is Dynamic calls?
If I have a choice to make it static or dynamic what should be my choice?
In short, what are merits and demerits of both static and dynamic calls?
Thank you in advance |
|
Back to top |
|
|
sribks2005
New User
Joined: 04 Apr 2005 Posts: 20 Location: Mysore
|
|
|
|
hi,
If storage is of main concern, then we can go for "Dynamic call" as module will be loaded to main memory only when it is called/needed.
If speed is of main concern, then we can go for "Static Call" as all modules will be link-edited together into the calling module during compilation process only.
Correct, if any mistakes here.
Thanks |
|
Back to top |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
Back to top |
|
|
dhirend
New User
Joined: 04 Jul 2005 Posts: 1
|
|
|
|
The dynamic and static calling depends on Compiler options only.
U can check a program is calling other pgm dynamically/ statically by looking at the load module.
Suppose program XYZ is calling ABC , then the load module of XYZ in case of dynamic calling will not have any other load module.
If XYZ has a static call to ABC , in that case load module of XYZ will be having load module of ABC also attached to it. If XYZ is calling more then one programs static way , then u will find all those load modules attached in the load module of XYZ.
In case of static calling , first u will have to compile the called programs and then compile the main program. |
|
Back to top |
|
|
venkatesh29 Warnings : 1 New User
Joined: 04 Oct 2005 Posts: 3
|
|
|
|
Hi All,
Thanks for all your answers.
Regards,
Venkatesh |
|
Back to top |
|
|
rakesh.in.in
New User
Joined: 01 Mar 2007 Posts: 5 Location: Pune
|
|
|
|
In Static call- The called module and main module are link edited.
But in case of Dynam call- The called module and main module are exit as a separate module.
or
Use keyword Dynamic for Dynamic call |
|
Back to top |
|
|
Shobana Bhaskar
New User
Joined: 02 Mar 2007 Posts: 35 Location: Pennsylvania, US
|
|
|
|
Hi Dhirend,
How ll you identify load module of ABC is present in load module of XYZ? |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
Where I work, 99.9% of our calls are dynamic. The performance difference between the dynamic and static calls are insignificant in the grand scheme of things.
Dynamically called programs are much more easier to manage than static programs. The extra time you would spend managing 'static' subroutines would be much better spent doing other things - such as optimizing your DB2.
As always there are exceptions to this rule. But not many. Use dynamic calls and spend your extra time making sure your designs are solid. |
|
Back to top |
|
|
mahesh_yellale
New User
Joined: 25 Dec 2006 Posts: 3 Location: pune
|
|
|
|
static call
In static call the program is called by name of the progrm
e.g.
CALL "MAHESH"
and the progrm "MAHESH" is then included in the main memory and hence the main program along with the sub pgm. aretreated as a same load module in static call.
similarly as the subpgm is in main memory itincrease the main memory size and also faster to access the pgm
Dynamic call
Where in case of Dynamic call the program is called by variable e.g.
W-S-SECTION.
01 SUBPGM PIC X(6).
PROCEDURE DIVISION.
MOVE "MAHESH" TO SUBPGM.
CALL "MAHESH".
this example shows that the program has been called by the variable subpgm in which the value "MAHESH" is initialized and hence when you called pgm program it just called as a seperate load module and unlike static not included in the main memory also hence at the time of execution it takes time to search the subpgm and which in turn take more time time in compared to static call |
|
Back to top |
|
|
VIKAS GAIKWAD
New User
Joined: 30 Nov 2006 Posts: 33 Location: MUMBAI
|
|
|
|
Hi mmwife,
Quote: |
I doubt that Prasad is still interested, but for posterity, this is a succinct statemet of the issue:
If compiled as NODYNAM:
CALL 'literal' is a static call
CALL WS-label is a dynamic call |
If I compiled program as NODYNAM & CALL WS-label then how & why it is get converted to Dynamic call? The option is NODYNAM then it should be static call, but finally it gets converted to Dynamic call, How it happens? Whether CALL variable overrieds NODYNAM to DYNAM or it instructs compiler to convert it into Dynamic call.
Thanks,
Vikas. |
|
Back to top |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
Hi All...
This is explained in the manuals which is provided above....pls check that...
Thanks
Vasanth..... |
|
Back to top |
|
|
|