In VSE, and perhaps on MVS (z/OS) I believe at one time there were restrictions 
from using the COBOL STOP RUN statement when running a COBOL program as a CICS 
transaction or in a DL/I (IMS) region.  If I recall correctly it's because a 
STOP RUN used to terminate the entire subsystem region, rather than just ending 
the COBOL run unit and returning control back to the subsystem.

This appears to no longer be the case.  Now it appears that a STOP RUN simply 
terminates the current "COBOL run unit".  So if running under CICS or IMS, CICS 
or IMS gain control and are not themselves exited.  Which is a good thing!  :-)

Given this, can you think of any reason not to use STOP RUN if the desire is 
to, in fact, terminate the current run unit?  (Could perhaps be done in a 
called subroutine, where the desire is not to return to the caller but to 
"return to the operating environment.)

The main reason I ask is because of an interesting "quirk" with Enterprise 
COBOL's RETURN-CODE special register.  Take the following example.

MOVE 16 TO RETURN-CODE.
EXEC SQL ROLLBACK END-EXEC.
GOBACK.

In this case the program ends with RC = 0, not the expected RC = 16.  This is 
because the EXEC SQL does a COBOL call to a DB2 module.  When the DB2 module 
returns it sets R15 to zero, which implicitly resets RETURN-CODE back to zero.  
Not what is really desired!

Obviously one could make sure they only move something to RETURN-CODE 
immediately before a GOBACK or STOP RUN, but it still seems to me to require 
some more "subtle knowledge" than most COBOL programmers would remember.

Anyway, I want to make an RFE for Enterprise COBOL to support the COBOL 2002 
enhancement to STOP RUN, which is the addition of the an optional "STATUS" 
clause.  For example:

STOP RUN WITH ERROR STATUS 16.
STOP RUN WITH ERROR 12.
MOVE 4 TO RET-CODE

STOP RUN ERROR RET-CODE.

In this case you are forced to specify the return code only at the time of stop 
run.  (I would also ask for a compile option eliminating the use of 
RETURN-CODE, and certainly a restriction of using both RETURN-CODE and STOP RUN 
WITH STATUS in the same program.


The standard supports this only for STOP RUN and not for GOBACK, and thus my 
original question!

Also, would you vote for this RFE?

Frank Swarbrick

FirstBank - Lakewood, CO USA


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to