Problem:
A wrong CALL-CONVENTION can cause that the perform logic is falling through the EXIT at the end of a performed section or paragraph - especially when executing as EXE.
How can the correct CALL-CONVENTION be determined?
Resolution:
A CALL-CONVENTION is a collection of bits, where the bit "1" means (2**1) that the callee removes the parameter off the stack. E.g.:
This bit is set in the CALL-CONVENTIONs 2, 66, and 74
And is not set, if CALL-CONVENTION is omitted or is set to 0, or 8.
If (this part of) the call-convention is by mistake, the CALL is executed normally. But after the return from the called program the stackpointer is corrupted. The program executes the following instructions as nothing has happened - including subsequent CALLs. But on a EXIT SECTION or EXIT PARAGRAPH a fall through may occur - instead of a return to the PERFORM statement.
When the "CALL-CONVENTION 2 is CALLEE-REMOVES-STACK" is specified, the number of parameters must be given as exepted by the CALLEE, while in normal COBOL CALLs (i.e. without this CALL-CONVENTION) a wrong number of parametes does not cause this problem.
The code may look like this:
--------------------
AA Section.
AA-01.
... some code ....
CALL A-CONV "A-CALL" USING ...
... some code ....
CALL A-CONV "B-CALL" USING ...
... some code ...
CALL A-CONV "C-CALL" USING ...
... some code ...
AA-99.
EXIT.
BB SECTION.
--------------------
To figure out which call causes the problem the code may temporarily be recoded. Placing each call in a separate section (or paragraph like needed) let the fall through occur imediately after the call.
--------------------
AA Section.
AA-01.
... some code ....
perform C-1
... some code ....
perform C-2
... some code ...
perform C-3
... some code ...
AA-99.
EXIT.
C-1 Section.
CALL A-CONV "A-CALL" USING ...
EXIT.
C-2 Section.
CALL A-CONV "B-CALL" USING ...
EXIT.
C-3 Section.
CALL A-CONV "C-CALL" USING ...
EXIT.
BB SECTION.
--------------------