The RETURN statement either sorted records from the final phase of a sort operation or merged records during a merge operation.
RETURNfile-name- 1 RECORD [INTOidentifier -1]
NOT AT ENDimperative-statement-2
file-name-1 must be described by a sort-merge file description entry in the Data Division.
A RETURN statement may be used only within the range of an output procedure associated with a SORT or MERGE statement for file-name-1.
The INTO phrase must not be used when the input file contains logical records of various sizes as indicated by their record descriptions. The storage area associated with identifier-1 and the record area associated with file-name-1 must not be the same storage area.
When the logical records of a 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, which lie beyond the range of the current data record, are undefined at the completion of the execution of the RETURN statement.
The execution of the RETURN statement causes the next record, in the order specified by the keys listed in the SORT or MERGE statement, to be made available for processing in the record area associated with file-name-1.
If no next record exists in the file referenced by file-name-1, the at end condition exists and control is transferred to imperative-statement-1 in the AT END phrase.Execution continues according to the rules for each statement in imperative-statement-1. If a procedure branching or conditional statement that causes explicit transfer of control is executed, control is transferred in accordance with the rules for that statement; otherwise, upon completion of the execution of imperative-statement-1, control is transferred to the end of the RETURN statement and the NOT AT END phrase, if specified, is ignored.
When the at end condition occurs, execution of the RETURN statement is unsuccessful and the contents of the record area associated with file-name-1 are undefined. After the execution of imperative-statement-1 in the AT END phrase, no further RETURN statements may be executed as part of the current output procedure.
If the at end condition does not occur during the execution of a RETURN statement, then after the record is made available and after executing any implicit move resulting from the presence of an INTO phrase, control is transferred to imperative-statement-2 in the NOT AT END phrase, if specified; otherwise, control is transferred to the end of the RETURN statement.
If the INTO phrase is specified, the current record is moved from the input area to the area specified by identifier-1 according to the rules for the MOVE statement without the CORRESPONDING phrase. The implied MOVE does not occur if there is an at end condition. Any subscripting associated with identifier-1 is evaluated after the record has been returned and immediately before it is moved to the data item.
When the INTO phrase is used, the data is available in both the input record area and the data area associated with identifier-1.
RETURN Statement Example
COBOL Related Interview Questions
|VSAM Interview Questions||IBM - VSAM Interview Questions|
|IBM-CICS Interview Questions||JCL Interview Questions|
|IBM DB2 Interview Questions||IBM-JCL Interview Questions|
|DB2 Using SQL Interview Questions||IBM-JCL&VSAM Interview Questions|
|IBM Mainframe Interview Questions||COBOL, CICS, JCL, VSAM, DB2 Interview Questions|
|DB2 SQL Programming Interview Questions||IMS/DB Interview Questions|
|Mainframe DB2 Interview Questions|
Procedure Division Statements
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.