The RETURN statement transfers records from the final phase of a sort or merge operation to an OUTPUT PROCEDURE.
The RETURN statement can be used only within the range of an output procedure associated with a SORT or MERGE statement.
RETURN Statement - Format >>-RETURN--file-name-1--+--------+--+--------------------+------> '-RECORD-' '-INTO--identifier-1-' >--+----+--END--imperative-statement-1--------------------------> '-AT-' >--+------------------------------------------+-----------------> '-NOT--+----+--END--imperative-statement-2-' '-AT-' >--+------------+---------------------------------------------->< '-END-RETURN-'
Within an OUTPUT PROCEDURE, at least one RETURN statement must be specified.
When the RETURN statement is executed, the next record from file-name-1 is made available for processing by the OUTPUT PROCEDURE.
The record areas associated with file-name-1 and identifier-1 must not be the same storage area.
If more than one record description is associated with file-name-1, these records automatically share the same storage; that is, the area is implicitly redefined. After RETURN statement execution, only the contents of the current record are available; if any data items lie beyond the length of the current record, their contents are undefined.
RETURN file-name-1
MOVE record-name TO identifier-1
Identifier-1 can be a DBCS, floating-point, or date-time data item.
Moving takes place according to the rules for the MOVE statement without the CORRESPONDING phrase.
The size of the current record is determined by rules specified for the RECORD clause. If the file description entry contains a RECORD IS VARYING clause, the implied MOVE is a group move. However, the implied MOVE does not occur when the RETURN statement is unsuccessful.
Any subscripting, indexing, or reference modification associated with identifier-1 is evaluated after the record has been returned and immediately before it is moved to identifier-1.