The GIVING/RETURNING phrase is not allowed for programs called with a linkage
type of program. GIVING and RETURNING are equivalent.
- identifier-4
- The RETURNING data item which must be defined in the DATA DIVISION.
The return value of the called program is implicitly stored into identifier-4.
Identifier-4 cannot be reference modified.
Identifier-4 can be a date-time data item.
- ADDRESS OF special register
- For information about this special register, see page ADDRESS OF Special Register.
You can specify the RETURNING phrase on calls to ILE procedures that return
a value. If you specify the RETURNING phrase on a CALL to a COBOL subprogram:
- The called subprogram must specify the RETURNING phrase on its PROCEDURE
DIVISION header.
- Identifier-4 and the corresponding PROCEDURE DIVISION RETURNING identifier
in the target program must have the same number of character positions and
must be of the same USAGE and SIGN clause and category. If identifier-4 is
defined using a TYPE clause, the item referenced in the GIVING/RETURNING phrase
of the PROCEDURE DIVISION header of the called program must also be defined
using a TYPE clause: the same type-name must be referenced in both TYPE clauses.
When control returns to the calling program, identifier-4 or its ADDRESS of
special register will contain the return value.
If an EXCEPTION or OVERFLOW occurs, identifier-4 is not changed.
The existence of the RETURNING phrase has no effect on the setting of the
RETURN-CODE special register.
Items referenced in the RETURNING/GIVING phrase of the CALL
statement cannot contain the TYPE phrase.