RETURN Statement [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
RETURN Statement
The RETURN statement can be used in an output procedure of a SORT or
MERGE statement. It cannot be used in any other type of procedure.
When used, the RETURN statement obtains either sorted records from the
final phase of a sort operation, or merged records during a merge
operation. Each record is obtained by a RETURN statement in the order
specified by the keys listed in the SORT or MERGE statement. These
records are made available for processing in the record area associated
with the sort or merge file, and, optionally, to another data area.
Syntax
Parameters
file-name-1 the name of the file used as the sort or
merge file in the SORT or MERGE statement
associated with the output procedure in
which the RETURN statement appears. It must
be described in a sort/merge file
description entry (SD level) in the DATA
DIVISION.
identifier-1 the name of a data item in your program.
The storage area referenced by identifier-1
must not be the same as the record area
associated with file-name-1.
imperative-statement-1 and one or more imperative statements.
imperative-statement-2
Description
When logical records of a sort/merge file are described with more than
one record description, these records automatically share the same
storage area. This is equivalent to an implicit redefinition of the
area. The contents of any data items that lie beyond the range of the
current data record are undefined at the completion of the execution of
the RETURN statement.
INTO Phrase
The INTO phrase, if specified in the RETURN statement, moves the current
record into the record area associated with file-name-1, and then uses an
implicit MOVE statement (without the CORRESPONDING phrase) to move a copy
of the data from the record area to the storage area referenced by
identifier-1. Thus, the data obtained from the SORT or MERGE statement
is available in the data area associated with identifier-1 as well as to
the input record area.
Any subscripting or indexing associated with identifier-1 is evaluated
after the record has been returned to the file, and immediately before it
is moved to the storage area referenced by identifier-1.
The INTO phrase must not be used when the input file contains logical
records of various sizes as indicated by their record descriptions.
AT END Phrase
If no next logical record exits for the file at the time a RETURN
statement executes, an AT END condition occurs. The contents of the
record areas associated with the file when the AT END condition occurs
are undefined; however, if the INTO phrase was used, the contents of
identifier-1 are the data moved into it by the preceding execution of the
RETURN statement.
When the AT END condition occurs, the imperative-statement-1 in the AT
END phrase is executed. Following execution of imperative-statement-1,
no RETURN statement may be executed as a part of the current output
procedure.[REV BEG] For more information on handling I/O errors, see
"Input-Output Error Handling Procedures" .[REV END]
MPE/iX 5.0 Documentation