You use the SORT-RETURN special register to detect errors in SORT or MERGE operations. The SORT-RETURN special register contains a return code indicating the success or failure of a SORT or MERGE operation. The SORT-RETURN special register contains a return code of 0 if the operation was successful or 16 if the operation was unsuccessful.
You can set the SORT-RETURN special register to 16 in an error declarative or input/output procedure to end a SORT/MERGE operation before all of the records have been processed. The operation ends before a record is returned or released.
The SORT-RETURN special register has the implicit definition:
01 SORT-RETURN GLOBAL PIC S9(4) USAGE BINARY VALUE ZERO.
When used in a nested program, the SORT-RETURN special register is implicitly defined as GLOBAL in the outermost ILE COBOL program.
Refer to the SORT and MERGE statements in the WebSphere Development Studio: ILE COBOL Reference for further information about the SORT-RETURN special register.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.