subprogram:Static and dynamic call



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

subprogram:Static and dynamic call

Postby Kasikannan » Mon Apr 04, 2011 1:12 pm

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
Kasikannan
 
Posts: 5
Joined: Mon Apr 04, 2011 12:04 pm
Has thanked: 0 time
Been thanked: 0 time

Re: subprogram:Static and dynamic call

Postby BillyBoyo » Mon Apr 04, 2011 2:03 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: subprogram:Static and dynamic call

Postby Robert Sample » Mon Apr 04, 2011 2:43 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: subprogram:Static and dynamic call

Postby BillyBoyo » Tue Apr 05, 2011 3:08 am

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: subprogram:Static and dynamic call

Postby Kasikannan » Thu Apr 07, 2011 12:30 pm

Many thanks to all.
Kasikannan
 
Posts: 5
Joined: Mon Apr 04, 2011 12:04 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post