ILE COBOL Programmer's Guide

Determining Whether the Sort or Merge Was Successful

After a sort or merge operation is completed, a return code or completion code is stored in the SORT-RETURN special register. The SORT-RETURN special register contains a return code of 0 if the sort or merge operation was successful, or it contains 16 if the sort or merge operation was unsuccessful.

The contents of the SORT-RETURN special register changes after each SORT or MERGE statement is performed. You should test for successful completion after each SORT or MERGE statement. For example:

 PROCEDURE DIVISION.
        
·
·
·
SORT SORT-WORK-2 ON ASCENDING KEY SORT-KEY INPUT PROCEDURE 600-SORT3-INPUT-PROC OUTPUT PROCEDURE 700-SORT3-OUTPUT-PROC. IF SORT-RETURN NOT EQUAL TO 0 DISPLAY "SORT ENDED ABNORMALLY. SORT-RETURN = " SORT-RETURN  
·
·
·
600-SORT3-INPUT-PROC SECTION.  
·
·
·
700-SORT3-OUTPUT-PROC SECTION.  
·
·
·


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]