Using the RETURN-CODE special register
About this task
When a COBOL program returns to
its caller, the contents of the RETURN-CODE
special register are
stored into register 15.
When control is returned to a
COBOL program or method from a call, the contents of register 15
are stored into the RETURN-CODE
special register of the calling program or
method.
When control is returned from a COBOL program to the
operating system, the special register contents are returned as a
user return code.
You might need to think about this handling of
the RETURN-CODE
special register when control is returned to a
COBOL program from a non-COBOL program.
If the non-COBOL program
does not use register 15 to pass back the return code,
the RETURN-CODE
special register of the COBOL program might be
updated with an invalid value.
Unless you set this special register
to a meaningful value before your Enterprise COBOL program returns to the
operating system, a return code that is invalid will be passed to
the system.
For equivalent function between
COBOL and C programs, have your COBOL program call the C program
with the RETURNING
phrase.
If the C program (function) correctly
declares a function value, the RETURNING
value of the calling COBOL program will be
set.
You cannot set the RETURN-CODE
special
register by using the INVOKE
statement.