MainframeSupports
tip week 30/2010:

For many years I have thought it was not worth the time writing a tip about dynamic calls from COBOL. Then I got caught in a discussion about how much more expensive it is to make dynamic calls compared to static calls. If you do not know about the difference between dynamic and static calls: If program A and B are part of the same load module and program A calls program B or vice versa it is a static call. If program A and program B are separated in each stand-alone load module and they call each other then it is a dynamic call.

In COBOL you can choose between dynamic and static call as you like and it has been that way as long as I remember. I actually beleive that this is the main reason for most installations to choose COBOL instead of PL/I. PL/I was recently (within the last 5 to 10 years) equipped with the same flexibility. In COBOL you call other programs by using CALL which comes in two flavours:

01 PROGRAMA PIC X(8) VALUE 'PROGRAMA'.
...
CALL 'PROGRAMA' USING ...
...or
CALL PROGRAMA USING ...

If compiler option DYNAM is used both CALL statements will compile into dynamic calls. If compiler option NODYNAM is used the first CALL (with the program name written as a constant) will compile into a static call while the other call (program name is specified in a variable) will continue to be dynamic. With option NODYNAM you have the option of mixing dynamic and static calls which can lead to confusion and problems which I will not discuss in this tip.

Actually my main objective in this tip is to tell you about my observations about the overhead when performing dynamic calls. Basically the overhead when using dynamic calls compared to static calls must only be the extra time used to load the called program into storage the first time the program is called. After that there should be no overhead. If you call a very simple prgram that does nothing but return to the caller straight away, you are able to measure the real overhead. To my big surprise it is twice as expensive to perform a dynamic call than a static call and not just at the first call, but also at all the following calls.

The overhead is not substansial, but if you are going to call the same program a lot of times and the called program performs simple things (like date validation) then you should consider calling such programs static. My measurements were performed using TSO so it might be different using CICS. There may also be variations in the COBOL runtime modules depending on the release.

Previous tip in english        Sidste danske tip        Tip list