RETURNS option and attribute
If a procedure is a function procedure, you must specify the RETURNS option on the procedure statement. Further, in the invoking procedure or package, you must declare such a procedure as an entry with the RETURNS attribute.
The RETURNS option and the RETURNS attribute are used to specify the attributes of the value that is being returned. The attributes in the RETURNS option must match the attributes in the RETURNS attribute.
Procedures that are subroutines (and are therefore invoked by the CALL statement) must not have the RETURNS option on the procedure statement and their entry declaration must not have the RETURNS attribute.
If more than one attribute is specified, they must be separated by blanks (except attributes such as precision that are enclosed in parentheses).
The attributes are specified in the same way as they are in a declare statement. Defaults are applied in the normal way.
- all data attributes
- the alignment attributes ALIGNED and UNALIGNED
- the non-data attributes BYVALUE/BYADDR, DATE, VALUELIST, and VALUERANGE
String lengths and area sizes must be specified by constants. The returned value has the specified length or size.
RETURNS(BYVALUE) is invalid with any of the following attributes: AREA, PICTURE, VARYING, VARYINGZ.
The BYADDR attribute must be in effect if a procedure contains any ENTRY statements and the procedure or any of its secondary entry points returns no value or an aggregate value.
On z/OS®, BYADDR is the default for RETURNS. If a C function is called, BYVALUE must be specified in the list of attributes for RETURNS.
