The GOBACK statement marks the logical end of a called program.
You can also return values to calling runtime elements written in any language or to the operating system environment.
General Format
Syntax Rules
If a GOBACK statement appears in a consecutive sequence of imperative statements within a sentence, it must appear as the
last statement in that sequence.
This rule is not enforced, although any statements in the sentence that follow the GOBACK statement are not executed.
GIVING and RETURNING are equivalent.
The data item referenced by identifier-1 must be no larger than 8 bytes in size.
Integer-1 may be signed.
General Rules
If a GOBACK statement is executed in a program which is under the control of a calling runtime element, the object program
operates as if executing an EXIT PROGRAM statement that has the same clauses as the GOBACK statement. See the topic
The EXIT Statement.
If a GOBACK statement without the ADDRESS OF clause is executed in a program which is not under the control of a calling runtime
element, the object program operates as if executing a STOP RUN statement that has the same clauses as the GOBACK statement.
If a GOBACK statement with the ADDRESS OF clause is executed in a program which is not under the control of a calling runtime
element, the object program operates as if executing a STOP RUN statement except that an arbitrary returned value is set in
the system area. The GOBACK statement may result in more compact code than the equivalent EXIT PROGRAM and STOP RUN statement.
A GOBACK statement must not be executed while executing a declarative procedure in which the GLOBAL phrase is specified except
in a program called while executing that declarative procedure.
If a GOBACK statement is executed in a function, the function operates as if executing an EXIT FUNCTION statement.
If a GOBACK statement is executed in a method, the method operates as if executing an EXIT METHOD statement.
If a GOBACK statement is executed in an iterator, the iterator operates as if executing an EXIT ITERATOR statement.