Data-name-2 is an output-only parameter. It specifies a data item to be returned as a program result. You must define data-name-2 in the LINKAGE or WORKING-STORAGE section. It can not be subscripted or reference modified.
Data-name-2 can be an internal or external floating-point, DBCS, date, time, or timestamp data item.
When a program returns to its invoker, the value in data-name-2 is implicitly stored into the identifier specified in the CALL RETURNING phrase.
The existence of the RETURNING phrase has no effect on the setting of the RETURN-CODE special register.
If the calling program is COBOL, it must specify the GIVING/RETURNING phrase of the CALL statement. In addition, data-name-2 and the corresponding CALL RETURNING identifier in the calling program must have the same number of character positions and must be of the same USAGE clause, SIGN clause and category.
Do not use the PROCEDURE DIVISION RETURNING phrase in main programs. The results are unpredictable. You should only specify the PROCEDURE DIVISION RETURNING phrase on called subprograms. For main programs, use the RETURN-CODE special register to return a value to the operating environment.
Items referenced in the RETURNING/GIVING phrase of the PROCEDURE DIVISION header cannot contain the TYPE phrase.