Handling Errors in Sort/Merge Operations
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.
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 IBM® Rational® Development Studio for i: ILE COBOL Reference for further information about the SORT-RETURN special register.