Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exit program vs. Goback

345 views
Skip to first unread message

Lanny Levine

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
Readers,

I just recently came across an 'EXIT PROGRAM' in a called module. At
work, as far as I know, we use GOBACK exclusively in batch programs. I have
read the appropriate sections in 'IBM COBOL for MVS & VM - Language
Reference' SC26-4769-01 and can only see one possible difference: GOBACK can
be used in a main program to return control to the OS whereas EXIT PROGRAM
cannot be coded in a main program.

I can see no difference between GOBACK and EXIT PROGRAM in called
programs. Do you know of any?

Thanks,

Lanny

Leif Svalgaard

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
Lanny Levine wrote in message ...

> I can see no difference between GOBACK and EXIT PROGRAM in called
>programs. Do you know of any?


If you don't know (or will allow both) if a program is a main program or a
called
program, GOBACK is useful to exit the program. It is strictly speaking not
needed as the construction:

RETURN-FROM-PROGRAM.
EXIT PROGRAM
.
STOP-THE-RUN.
STOP RUN
.

has the same effect has GOBACK, but GOBACK is handier that
the above construction.

Steve Shriver

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
In article <japC2.8497$jf2.3...@hme2.newscontent-01.sprint.ca>,

"Lanny Levine" <lle...@sprint.ca> wrote:
> Readers,
>
> I just recently came across an 'EXIT PROGRAM' in a called module. At
> work, as far as I know, we use GOBACK exclusively in batch programs. I have
> read the appropriate sections in 'IBM COBOL for MVS & VM - Language
> Reference' SC26-4769-01 and can only see one possible difference: GOBACK can
> be used in a main program to return control to the OS whereas EXIT PROGRAM
> cannot be coded in a main program.
>
> I can see no difference between GOBACK and EXIT PROGRAM in called
> programs. Do you know of any?
>
> Thanks,
>
> Lanny
>
> Lanny,
My manual says:

The GOBACK statement is equivalent to the statement sequence
EXIT PROGRAM; STOP RUN

But you can also return a value to the OS if you use

GOBACK RETURNING (RETURN-VALUE)

I don't use this much, so you will have to take it from here.
Steve S

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

Twymer

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
The difference is that Exit Program MUST appear on a line by it iteself and
GOBACK does not. I understand that GOBACK was included in VS COBOL II for
backwards compatibility with older programs and is not an ANSI standard. The
recommendation is to use EXIT PROGRAM as support for GOBACK may be dropped
soon.

Tom Wymer

William M. Klein

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
This post isn't true.

Exit Program can be coded any way that you want.

GoBack will be in the next Standard.

The original question was whether or not GoBack and Exit Program were the
same in a subprogram and the answer is YES, they are defined to be
identical. The only difference is that GoBack is also equivalent to Stop
Run in a main program - so you don't need to know whether you are in a
subprogram or a main program when you code it.

--
Bill Klein (wmklein at ix dot netcom dot com)

Twymer wrote in message <19990301084045...@ng-cg1.aol.com>...

docd...@clark.net

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
In article <7beco3$m...@sjx-ixn5.ix.netcom.com>,

William M. Klein <wmk...@inospam.netcom.com> wrote:
>This post isn't true.
>
> Exit Program can be coded any way that you want.
>
>GoBack will be in the next Standard.
>
>The original question was whether or not GoBack and Exit Program were the
>same in a subprogram and the answer is YES, they are defined to be
>identical. The only difference is that GoBack is also equivalent to Stop
>Run in a main program - so you don't need to know whether you are in a
>subprogram or a main program when you code it.

Oh dear... well, at the risk of making myself look foolish let me, once
again, state my understandings, preferences and prejudices... which, of
course, are better'n anyone elses:

GOBACK returns control to the invoking program; in the case of a MAIN
program it returns control to the operating system. There are *no*
difficulties or potential difficulties of which I am aware which one might
encounter when terminating execution of a program with a GOBACK.

STOP RUN does... something else which I do not have the terminology to
describe; STOP RUN stops, in my experience, *everything* associated with a
program and returns control to the operating system (or something like
that). If a STOP RUN is issued in a subroutine (in certain environments
and platforms) then not only is the subroutine terminated but the MAIN
program is terminated as well.. Big Fun for debugging!

Since *anything* can be done with *any* program at *any* time it can be
concluded that, at any time, any MAIN program can be turned into a
subroutine for another program. It is with this eventuality in mind that
I, personally, *only* code GOBACKs.

DD

Shaun C. Murray

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
On Mon, 1 Mar 1999 00:00:23 -0500, "Lanny Levine" <lle...@sprint.ca>
wrote:


> I can see no difference between GOBACK and EXIT PROGRAM in called
>programs. Do you know of any?

EXIT PROGRAM is ANSI standard and GOBACK isn't.

--
Shaun
s...@enterprise.net PGP Key available
GoFar MTB mag (Issue 2 now available) http://www.gofar.demon.co.uk/

Shaun C. Murray

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
On Mon, 01 Mar 1999 13:49:59 GMT, Steve Shriver
<stev...@my-dejanews.com> wrote:


>The GOBACK statement is equivalent to the statement sequence
>EXIT PROGRAM; STOP RUN
>
> But you can also return a value to the OS if you use
>
> GOBACK RETURNING (RETURN-VALUE)
>
> I don't use this much, so you will have to take it from here.

With Micro Focus COBOL you can also do

EXIT PROGRAM RETURNING .....

so they are pretty much the same in that respect.

Howard Brazee

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
> > I can see no difference between GOBACK and EXIT PROGRAM in called
> >programs. Do you know of any?
>
> EXIT PROGRAM is ANSI standard and GOBACK isn't.

It will soon be, so that's not an issue.

Volker Bandke

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to


Depends what you mean with "SOON"..., 2003 is my guestimate
with kind regards

Volker Bandke
(BSP GmbH)

Simon Cordingley

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
Every COBOL program I have ever seen has used a GOBACK (Lots of IBM
experience) for both MAIN and SUB programs/routines. Could be lots and lots
of maintenance in the future! We even use it for documentation purposes in
CICS programs.

(Good question - is the GOBACK needed in a CICS program?)

Simon Cordingley
Casegen Systems Ltd
www.casegen.co.uk


Volker Bandke wrote in message <36daff7d...@news3.ibm.net>...

William M. Klein

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to

James King wrote in message ...
>You're close but no see gar: (sic)
>
>GOBACK results in an UNCONDITIONAL RETURN to CALLER. NO MATTER whether
Main
>or SUB. In a SUB there is no difference
>HOWEVER, (the ONLY difference between a Main and SUB is whether
>the Linkage Section has a 2byte length item. MVS/OSVS provides this
>to ALL EXEC PGM= programs (so that the length of parms can be determined).
>SO, if you run a Sub as a EXEC PGM= (say no data is passed)
>the EXIT PROGRAM is 'NOP'ed so the NEXT SEQUENTIAL INSTRUCTION IS EXECUTED.
>


Which is JUST exactly what the ANSI/ISO Standard *demands* will happen when
you do an EXIT PROGRAM in a "main" program (i.e. it is treated like a
CONTINUE).

--
Bill Klein

James King

unread,
Mar 2, 1999, 3:00:00 AM3/2/99
to
You're close but no see gar: (sic)

GOBACK results in an UNCONDITIONAL RETURN to CALLER. NO MATTER whether Main
or SUB. In a SUB there is no difference
HOWEVER, (the ONLY difference between a Main and SUB is whether
the Linkage Section has a 2byte length item. MVS/OSVS provides this
to ALL EXEC PGM= programs (so that the length of parms can be determined).
SO, if you run a Sub as a EXEC PGM= (say no data is passed)
the EXIT PROGRAM is 'NOP'ed so the NEXT SEQUENTIAL INSTRUCTION IS EXECUTED.

(I just finished a 2000 line assembler Dynamic Allocation/Delete
subroutine/Main program that I made able to be 'called' or 'Execed' by
checking byte 1 of the passed data for X'00' (it will never get more
than 116 bytes which is X'7F' and so the 2 byte Comp pointer is always
less than X'0080'. If byte 1 is X'00' then I bump up the pointer by 2 bytes
whichthen points the my data from mvs.


Lanny Levine wrote in message ...

>Readers,
>
> I just recently came across an 'EXIT PROGRAM' in a called module. At
>work, as far as I know, we use GOBACK exclusively in batch programs. I have
>read the appropriate sections in 'IBM COBOL for MVS & VM - Language
>Reference' SC26-4769-01 and can only see one possible difference: GOBACK
can
>be used in a main program to return control to the OS whereas EXIT PROGRAM
>cannot be coded in a main program.
>

> I can see no difference between GOBACK and EXIT PROGRAM in called
>programs. Do you know of any?
>

> Thanks,
>
> Lanny
>
>

Shaun C. Murray

unread,
Mar 2, 1999, 3:00:00 AM3/2/99
to
On Mon, 1 Mar 1999 21:32:05 -0000, "Simon Cordingley"
<sim...@casegen.co.uk> wrote:

>Every COBOL program I have ever seen has used a GOBACK (Lots of IBM
>experience) for both MAIN and SUB programs/routines. Could be lots and lots
>of maintenance in the future! We even use it for documentation purposes in
>CICS programs.

You can spot a CICS programmer a mile off by the use of GOBACK. ;-)

Any idea why IBM invented GOBACK instead of just re-using EXIT
PROGRAM?

Being a Micro Focus programmer I've always EXIT PROGRAM [RETURNING
..] myself.

>
>(Good question - is the GOBACK needed in a CICS program?)

No idea. Certainly not wanted in any of my non-CICS programs. GOBACK
in a main program just doesn't make sense to me. GOBACK where?

S Comstock

unread,
Mar 2, 1999, 3:00:00 AM3/2/99
to
Shaun C. Murray writes...

[snip]

>No idea. Certainly not wanted in any of my non-CICS programs. GOBACK
>in a main program just doesn't make sense to me. GOBACK where?
>

Actually, GOBACK makes perfect sense. It says GOBACK to whoever called you. If
you are a subroutine, it returns to the mainline; if you are a main program, it
returns to the operating system. There is no need to remember EXIT PROGRAM vs.
STOP RUN: GOBACK satisfies both needs, a gentle multi-purpose statement.

Regards,


Steve Comstock
Telephone: 303-393-8716
www.trainersfriend.com
email: st...@trainersfriend.com
256-B S. Monaco Parkway
Denver, CO 80224
USA

Volker Bandke

unread,
Mar 2, 1999, 3:00:00 AM3/2/99
to
On Mon, 1 Mar 1999 21:32:05 -0000, "Simon Cordingley" <sim...@casegen.co.uk> wrote:

>Every COBOL program I have ever seen has used a GOBACK (Lots of IBM
>experience) for both MAIN and SUB programs/routines. Could be lots and lots
>of maintenance in the future! We even use it for documentation purposes in
>CICS programs.
>

>(Good question - is the GOBACK needed in a CICS program?)
>

Standard answer number 1: It depends.

a) The compiler in use is OLD (OS/VS COBOL). Then the compiler complains it it doesn't
find a GOBACK or EXIT PROGRAM or STOP RUN anywhere in the program. Therefore standard
programming practice was to put a GOBACK immediately after the EXEC CICS RETURN END-ENXEC,
where, of course, it would never be reached

b) The CICS program in question is a VS COBOL II (or higher) program and has been invoked
via a COBOL CALL. Then it should return to the MAIN program using GOBACK, and not EXEC
CICS RETURN

William M. Klein

unread,
Mar 2, 1999, 3:00:00 AM3/2/99
to

Shaun C. Murray wrote in message <36dbc94f...@news.enterprise.net>...

>On Mon, 1 Mar 1999 21:32:05 -0000, "Simon Cordingley"
><sim...@casegen.co.uk> wrote:
>
>>Every COBOL program I have ever seen has used a GOBACK (Lots of IBM
>>experience) for both MAIN and SUB programs/routines. Could be lots and
lots
>>of maintenance in the future! We even use it for documentation purposes in
>>CICS programs.
>
>You can spot a CICS programmer a mile off by the use of GOBACK. ;-)
>
>Any idea why IBM invented GOBACK instead of just re-using EXIT
>PROGRAM?
>
>Being a Micro Focus programmer I've always EXIT PROGRAM [RETURNING
>..] myself.
>


Because (as I thought this stream made quite clear) GoBack and Exit Program
are really quite different. They are IDENTICAL in a subprogram, but in a
MAIN program, GoBack is equivalent to Stop Run. There was (and is) no
ANSI/ISO Standard way of ending a program if you don't know whether you are
in a SubProgram or Main program. This is what the statement solves (and
will solve in the next Standard).

Shaun C. Murray

unread,
Mar 3, 1999, 3:00:00 AM3/3/99
to
On Tue, 2 Mar 1999 12:08:02 -0600, "William M. Klein"
<wmk...@nospam.netcom.com> wrote:


>
>
>Because (as I thought this stream made quite clear) GoBack and Exit Program
>are really quite different. They are IDENTICAL in a subprogram, but in a
>MAIN program, GoBack is equivalent to Stop Run.

No, I understood that quite clearly. Worked that out the first time I
came across GOBACK in other peoples source.

> There was (and is) no
>ANSI/ISO Standard way of ending a program if you don't know whether you are
>in a SubProgram or Main program. This is what the statement solves (and
>will solve in the next Standard).

I guess I always know if I'm in a sub or main program in the software
I design but it's pretty much not your typical CICS style system. The
other solution for that problem I've seen is to put EXIT PROGRAM
followed by STOP RUN in your programs.

Kerry Ellis

unread,
Mar 4, 1999, 3:00:00 AM3/4/99
to
There was (and is) no ANSI/ISO Standard way of ending 
a program if you don't know whether you are in a 
SubProgram or Main program.


Oh? What was (and is) wrong with Exit Program immediately
followed by a Stop Run (plus, of course, the appropriate para-
graph headers inserted so that the code conforms to the std)?
A bit unwieldy perhaps, but perfectly standard (and it works,
too!).  The introduction of the GOBACK statement into the
standard just makes coding such "I don't know what invoked
me" programs easier (and turns thousands of nonstandard batch
Cobol programs written without any concern for the standard
(but with a nod and a "Thank you" to IBM extensions that allow
the programmer to save precisely two keystrokes) into standard
ones).

William M. Klein wrote:

Shaun C. Murray wrote in message <36dbc94f...@news.enterprise.net>...
>On Mon, 1 Mar 1999 21:32:05 -0000, "Simon Cordingley"
><sim...@casegen.co.uk> wrote:
>
>>Every COBOL program I have ever seen has used a GOBACK (Lots of IBM
>>experience) for both MAIN and SUB programs/routines. Could be lots and
lots
>>of maintenance in the future! We even use it for documentation purposes in
>>CICS programs.
>
>You can spot a CICS programmer a mile off by the use of GOBACK. ;-)
>
>Any idea why IBM invented GOBACK instead of just re-using EXIT
>PROGRAM?
>
>Being a Micro Focus programmer I've always EXIT PROGRAM [RETURNING
>..] myself.
>

Because (as I thought this stream made quite clear) GoBack and Exit Program

are really quite different.  They are IDENTICAL in a subprogram, but in a

MAIN program, GoBack is equivalent to Stop Run.  There was (and is) no

ANSI/ISO Standard way of ending a program if you don't know whether you are
in a SubProgram or Main program.  This is what the statement solves (and
will solve in the next Standard).

--

William M. Klein

unread,
Mar 4, 1999, 3:00:00 AM3/4/99
to
It is true that the following ANSI/ISO conforming code is "equivalent" to a
GoBack,

Perform GoBack-Para1
Perform GoBack-Para2
.
GoBack-Para1.
Exit Program.
GoBack-Para2.
Stop Run.

On the other hand, it is also true that you can code "equivalents" to
STRING, UNSTRING, and INSPECT via "simpler" verbs - but I wouldn't call that
really "existing" functionality. Several people (used to) claim that you
could just code

Exit Program
Stop Run.

as a sequence of statements in an ANSI/ISO conforming program, but it
violated the rules of NOT having other statements in a "sequence" with an
EXIT PROGRAM statement. I don't think that any of us are really arguing
about the usefulness of GoBack.

P.S. to Kerry and others,
If possible, please use "Plain text" rather than HTML when posting to
comp.lang.cobol. This isn't required, but it sure makes life easier for
many readers.

--
Bill Klein
wmklein at ix dot netcom dot com

Kerry Ellis wrote in message <36DEB2CF...@ms.com>...

Howard Brazee

unread,
Mar 5, 1999, 3:00:00 AM3/5/99
to
The first time I worked with IBM, we didn't use STOP RUN nor GOBACK.
Instead we did a call - was it CALL EXIT? I don't remember why except
that's what we were supposed to do.

Kerry Ellis

unread,
Mar 5, 1999, 3:00:00 AM3/5/99
to William M. Klein
> Several people (used to) claim that you
> could just code
>
> Exit Program
> Stop Run.
>
> as a sequence of statements in an ANSI/ISO conforming program, but it
> violated the rules of NOT having other statements in a "sequence" with an
> EXIT PROGRAM statement. I don't think that any of us are really arguing
> about the usefulness of GoBack.
>

I do not know who those "several people" were or are, but I am not among
them. However, I think that you are misinterpreting the Standard -- which
concerns me because, as I understand it, you are currently contributing to
the new Revision (if not, then please accept my most humble apologies).

I assert that the following is perfectly correct; i.e.: standard:

.
.
.
CLOSE INPUT-FILE, OUTPUT-FILE.

998-RETURN-TO-CALLER.
EXIT PROGRAM.

999-RETURN-TO-OPERATING-SYS.
STOP RUN.

where the program falls from the last statement in the paragraph prior to
#998 (i.e.: the CLOSE statement; assuming that that paragraph is not
part of a PERFORMed procedure), and either executes the EXIT PROGRAM
if this is a called subprogram, or treats it as a no-op, falls through it, and
executes the STOP RUN, thereby terminating the "run unit" if this is a main
program.

Although IBM's manual is not a verbatim copy of the ANSI or ISO standard
documents, I doubt that it would have misinterpreted the standard lo these
several decades. Here is what a recent IBM "COBOL for MVS Language
Reference" manual says:

> If control reaches an EXIT PROGRAM statement, and no CALL statement
> is active, control passes through the exit point to the next executable statement.

Your example of a sequence of Performed paragraphs, one containing an EXIT
PROGRAM and one containing a STOP RUN is -- IMHO -- spurious because
(despite the presence of a plethora of PERFORM statements) Performing a
STOP RUN statement is NOT well structured.

And -- finally -- I would claim that GoBack is NOT very useful, but it is slightly
more convenient. I think that it is highly disingenuous to compare the kind of
code (usually pages and pages) necessary to provide "equivalences" to the
STRING, UNSTRING, and INSPECT statements with the coding of two
statements and two paragraph headers instead of a single GoBack statement.

Mind you, I cannot get myself all worked up about the presence of the GoBack
statement in the new standard; however, in the larger scheme of things, it is not
nearly as important as, say, adding a statement permitting the "early" exit
from a Performed procedure (I gather through the use of some new form of
the EXIT statement), or the implementation of recursive capabilities, or the
introduction of 4-digit year features into the ACCEPT (which will be hopelessly
moot by the time that the Standard is finally approved).

BTW, I just noticed that the restriction on EXIT PROGRAM being the last
statement in a sequence of imperative statements will be lifted at the SAME
time as GOBACK is introduced; therefore, the code fragment:

IF INPUT-IS-AT-END-OF-FILE
THEN
CLOSE INPUT-FILE
EXIT PROGRAM
STOP RUN
END-IF

will be perfectly legal (i.e.: "standard") as soon as GoBack is....

William M. Klein

unread,
Mar 5, 1999, 3:00:00 AM3/5/99
to
You are correct that using "fall thru logic" is valid with the current
Standard. (However, it is something that I just can't ever imagine
"recommending".) You are also correct that the restriction on EXIT Program
being the last statement in a sequence of statements is being removed at the
same time as the addition of GoBack.

Given both of these facts, I still can see no "advantage" of using either of
these techniques over the currently commonly available (as an extension) and
planned inclusion of GoBack. Your term is "slightly convenient" and I would
not claim that it is much more than that. However, I don't understand any
objection to "slightly convenient" and actually think that it is a "nice to
have" as are several other enhancements in the draft Standard.

The following is a list of several (but certainly not ALL) "slightly
convenient" features that (when added together) all seem to be VERY useful -
in the draft Standard. Almost all of these - like GoBack - are available
today as extensions in one or more implementations. (These are "summary"
phrases. For the exact feature, see the draft Standard)

- 31 digit numeric items
- Implementor defined successful status codes
- Apostrophe as synonym for quotation symbol
- Positive and Negative conditional phrases in any order (E.g.. NOT AT
END before AT END)
- Call using non-elementary or 01-level arguments
- Relative COLUMN number
- Optional PICTURE Clause with VALUE clause (report writer)
- Constants
- literals is COPY member and library name (also program-id name)
- Partial expressions in EVALUATE statement
- Method of making FUNCTION an optional word
- Expansion of where you can use numeric functions
- In-line comments
- INSPECT CONVERTING with multiply occurring items
- Optionally of paragraph-name at beginning of Procedure Division
- AFTER phrase with Inline PERFORM
- REDEFINES of other than the 1st item
- Dynamic file assignment via Select/Using (rather than Select/Assign)
- SORT of tables
- STOP with STATUS
- DELIMITED optional in STRING
- Subscripting with arithmetic expressions
- Underscore in COBOL character set
- Value clause allowed (but ignored) in Linkage Section and External
data
- WRITE from a literal

--
Bill Klein
wmklein at ix dot netcom dot com

Kerry Ellis wrote in message <36E04E56...@ms.com>...

Thane Hubbell

unread,
Mar 6, 1999, 3:00:00 AM3/6/99
to
On Fri, 5 Mar 1999 18:23:04 -0600, "William M. Klein"
<wmk...@nospam.netcom.com> wrote:


> - Partial expressions in EVALUATE statement

What does that mean?


William M. Klein

unread,
Mar 6, 1999, 3:00:00 AM3/6/99
to
I checked the rules and my last example is NOT valid. A "good" (valid)
example of the use would be:

Evaluate A
When > B
Perform X
When < C
Perform Y
When Positive
Perform Z
When Other
Display "Here we go again"
End-Evaluate

This is valid because the Selection OBJECT begins with a relational operator
or starts a class test - but the Selection SUBJECT is still an identifier.
(My original error was having the "dangling" relational operator - which I
think at one time was allowed but not by the current draft.)

--
Bill Klein
wmklein at ix dot netcom dot com

William M. Klein wrote in message <7bqeta$l...@sjx-ixn6.ix.netcom.com>...
>
>Thane Hubbell wrote in message <36e09afa....@news1.ibm.net>...


>>On Fri, 5 Mar 1999 18:23:04 -0600, "William M. Klein"
>><wmk...@nospam.netcom.com> wrote:
>>
>>

>>> - Partial expressions in EVALUATE statement
>>

>>What does that mean?
>>
>
>Instead of having to code
>
>Evaluate True
> When A > B
> Perform X
> When A > C
> Perform Y
> When A > D
> Perform Z
> When Other
> Display "Oh NO"
> End-Evaluate
>
>you now can code
>
> Evaluate A >
> When B
> Perform X
> When C
> Perform Y
> When D
> Perform Z
> When Other
> Display "Oh NO"
> End-Evaluate
>
>(I did this example without actually looking at the full text, but I think
>it gives the idea. This feature is already available - as an extension -
in
>Micro Focus (Merant) - and me be in other compilers as well.)
>
>

0 new messages