Page 1 of 1

subprogram:Static and dynamic call

PostPosted: Mon Apr 04, 2011 1:12 pm
by Kasikannan
Hi,

I want to know what type of call is this...

01 sub-prog pic x(8) value ' subprog1'.

Call sub-prog.

Compiler options used: NODYNAM

Does this call statement is dynamic or static.
My assumption is Static call since the option is NODYNAM.Please help

Re: subprogram:Static and dynamic call

PostPosted: Mon Apr 04, 2011 2:03 pm
by BillyBoyo
No it is a dynamic call. All "call data-name" calls are dynamic, no matter what the DYNAM/NODYNAM option is given to the compiler. Check in the compile options in the manual.

Re: subprogram:Static and dynamic call

PostPosted: Mon Apr 04, 2011 2:43 pm
by Robert Sample
From the COBOL Programming Guide manual:
2.4.20 DYNAM



Use DYNAM to cause nonnested, separately compiled programs invoked through the CALL literal statement to be loaded for CALL, and deleted for CANCEL, dynamically at run time. (CALL identifier statements always result in a runtime load of the target program and are not affected by this option.)

Note that the manual explicitly states that DYNAM/NODYNAM does not apply to your code.

Re: subprogram:Static and dynamic call

PostPosted: Tue Apr 05, 2011 3:08 am
by BillyBoyo
Look at it this way if it helps.

For a static call, the linkage-editor provides the address of the called program to the calling program. So a static call is only possible if the module to be called is known at compile time.

A dynamic call only gets an address for the called program at run time.

If you use "call data-name", it is not known at compile time (even if the data-name is a psudo literal, ie it is not changed in the program) what name might actually be called.

So only "call literal" (known value at compile time) can be static. By default, it is static, so if you want it dynamic (for all calls in the main program) you have to compile with the DYNAM option. If you have one module you want dynamic and others static, change the one module to "call data-name" with a value clause on the data-name.

"Call data-name" can only be dynamic. If you want it to be static, you have to change it to "call literal". If you were selecting which module to call by setting the value of the data-name, you have to use different selection logic to a number of "call literal" statements.

Re: subprogram:Static and dynamic call

PostPosted: Thu Apr 07, 2011 12:30 pm
by Kasikannan
Many thanks to all.