Can u explain Ur query in detail. bcz the return code depends on the input file also. since u had specified as for the particular Sort Statement!!! it will be 0 i think so. if the i/p or the o/p file structure differs then it will throw the RC according to that..
Joined: 03 Nov 2005 Posts: 46 Location: Shanghai, China
Hi~ I look up the IBM library book -- Enterprise COBOL for z/OS V3.4 Programming Guide. Hope it's helpful to you.
1.12.11 Determining whether the sort or merge was successful
The DFSORT program returns one of the following completion codes after a sort or merge has finished:
0 Successful completion of the sort or merge
16 Unsuccessful completion of the sort or merge
The completion code is stored in the SORT-RETURN special register. The contents of this register change after each SORT or MERGE statement is
You should test for successful completion after each SORT or MERGE statement. For example:
ON ASCENDING KEY SORT-KEY
INPUT PROCEDURE IS 600-SORT3-INPUT-PROC
OUTPUT PROCEDURE IS 700-SORT3-OUTPUT-PROC.
IF SORT-RETURN NOT=0
DISPLAY "SORT ENDED ABNORMALLY. SORT-RETURN = " SORT-RETURN.
. . .
. . .
. . .
If you do not reference SORT-RETURN anywhere in your program, the COBOL run time tests the return code. If the return code is 16, COBOL issues a
runtime diagnostic message.
If you test SORT-RETURN for one or more (but not necessarily all) SORT or MERGE statements, the COBOL run time does not check the return code.
By default, DFSORT diagnostic messages are sent to the SYSOUT data set. If you want to change this default, use the MSGDDN parameter of the
DFSORT OPTION control card or use the SORT-MESSAGE special register.