Can static call be changed into dynamic call while at runtime.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Baresh Ba
Registered Member
Posts: 15
Joined: Thu Oct 16, 2014 8:22 pm

Can static call be changed into dynamic call while at runtime.

Post by Baresh Ba »

Hi ,

Can a static call be changed to dynamic call during runtime in a COBOL program?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can static call be changed into dynamic call while at runtime.

Post by Robert Sample »

No. A static call means that the subprogram was linked into the program's load module and hence it is part of the program and can only be called by that program. A dynamic call means that the subprogram exists in a load library as a separate load module and can be called by multiple programs at the same time. There is no way to convert from one to the other while executing the program.
Baresh Ba
Registered Member
Posts: 15
Joined: Thu Oct 16, 2014 8:22 pm

Re: Can static call be changed into dynamic call while at runtime.

Post by Baresh Ba »

Thank you Robert. It was asked me in an interview question. I am not sure even if it could have been done what would be the use of such an arrangement?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can static call be changed into dynamic call while at runtime.

Post by Robert Sample »

The question was used to judge how well you understand COBOL calls. The advantages of static calls are they are slightly faster, and you won't get a run-time error for not finding the subprogram. The disadvantages are that if the subprogram has to be changed the main program has to be re-linked (which could be quite an adventure depending upon how many subprograms the main program has) and there is a run-time cost to locating and loading the subprogram. The advantages of dynamic calls is that they can be recompiled without affecting the main program, and multiple programs can use the same subprogram, and different versions of the subprogram can exist in different load libraries. The disadvantages of dynamic calls are that you have to have a STEPLIB pointing to the load library containing the subprogram, and they are slightly slower, and if you run the main program in a different LPAR it may use a different version of the subprogram.

There are times when a STEPLIB is not required, such as when the load library is in the LINK LIST concatenation, but then you can only access one version of the subprogram. One thing to be aware of is that CICS program calls are always dynamic now.
Baresh Ba
Registered Member
Posts: 15
Joined: Thu Oct 16, 2014 8:22 pm

Re: Can static call be changed into dynamic call while at runtime.

Post by Baresh Ba »

Thanks Robert.

So if a sub-program is changed, are we to compile all the main programs calling it? Whether or not the change in sub-program affects the main program?
User avatar
giskard reventlov
Registered Member
Posts: 11
Joined: Wed Jul 29, 2020 4:42 pm

Re: Can static call be changed into dynamic call while at runtime.

Post by giskard reventlov »

So if a sub-program is changed, are we to compile all the main programs calling it? Whether or not the change in sub-program affects the main program?
it would be wiser to reach an agreement on the terminology ...

if a dependency ( sub-program ) is changed the main-programs depending on it must be REBUILT,
if it is a full compile of everything or just a compile of the changed sub-program and a re-bind ( the term for the new linkage editor ) depends on Your change management tool setup
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can static call be changed into dynamic call while at runtime.

Post by Robert Sample »

if a dependency ( sub-program ) is changed the main-programs depending on it must be REBUILT,
if it is a full compile of everything or just a compile of the changed sub-program and a re-bind ( the term for the new linkage editor ) depends on Your change management tool setup
Depending upon what is changed in the subprogram, the main program may NOT need to be recompiled when a dynamic call is used. A dynamic call resolves the subprogram reference AT RUN TIME, not compile time, and hence the subprogram does not get linked in (bound) to the main program. What you described is a static call, which is totally different from a dynamic call. And we're not talking about a change management tool, we're talking about dynamic versus static calls (which are entirely language-dependent). A COBOL program that does not use DB2, for example, has no special requirements for linking / binding and dynamic subprograms have been supported in that environment for at least 20 to 30 years, if not longer.

If the change affects the interface between the main program and the subprogram, then of course the main program has to be recompiled as well. However, if the change only impacts the subprogram (such as changing a WORKING-STORAGE FILLER to a variable without changing the length), then the main program does not need to be recompiled.
User avatar
giskard reventlov
Registered Member
Posts: 11
Joined: Wed Jul 29, 2020 4:42 pm

Re: Can static call be changed into dynamic call while at runtime.

Post by giskard reventlov »

I was not talking about dynamic calls!
Baresh Ba
Registered Member
Posts: 15
Joined: Thu Oct 16, 2014 8:22 pm

Re: Can static call be changed into dynamic call while at runtime.

Post by Baresh Ba »

giskard reventlov wrote: Thu Dec 17, 2020 6:53 pmit would be wiser to reach an agreement on the terminology ...
I am not sure what terminology you are referring to? Could you please elaborate?
Baresh Ba
Registered Member
Posts: 15
Joined: Thu Oct 16, 2014 8:22 pm

Re: Can static call be changed into dynamic call while at runtime.

Post by Baresh Ba »

giskard reventlov wrote: Thu Dec 17, 2020 6:53 pmif a dependency ( sub-program ) is changed the main-programs depending on it must be REBUILT,
if it is a full compile of everything or just a compile of the changed sub-program and a re-bind ( the term for the new linkage editor ) depends on Your change management tool setup
Thanks but I've usually used 'BIND' in connection with COBOL-DB2 programs only.
User avatar
giskard reventlov
Registered Member
Posts: 11
Joined: Wed Jul 29, 2020 4:42 pm

Re: Can static call be changed into dynamic call while at runtime.

Post by giskard reventlov »

Thanks but I've usually used 'BIND' in connection with COBOL-DB2 programs only.
I am not that stupid :twisted:
if You had cared to stay updated on the latest IBM terminology You would have known that
the good old linkage editor has been renamed/promoted to binder.
( look Yourself for the different behaviour of the binder when binding to PDSs vs PDSEs )

and also You did not notice that I wrote ...
re-bind ( the term for the new linkage editor )
Baresh Ba
Registered Member
Posts: 15
Joined: Thu Oct 16, 2014 8:22 pm

Re: Can static call be changed into dynamic call while at runtime.

Post by Baresh Ba »

Robert - but why in the heaven we have static-calls there today? Do they really server any purpose?
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”