145 pts.
 COBOL INTERNAL SORT ERROR
Hello, I'm getting the following error on the 'OUTPUT' procedure of the internal sort,

'RETURN statement 2267 out of order'.

 Cause . . . . . : The RETURN statement was not expected by SORT/MERGE. Either a SORT/MERGE was not active or the statement was issued out of sequence. Message issued at statement 2267 of COBOL program 'IAHF910' in program object 'IAHF910' in library 'IAHFOBJ'.

 Recovery . . . : Remove the RETURN statement or place it in proper order.

I verified using STRDBG that the INPUT procedure is running and SORT records are being released.   

SORT SORT-FILE                                      ASCENDING KEY SREC-KEY                          INPUT PROCEDURE  P1000-DECLARE-TXN-SALE         OUTPUT PROCEDURE P2000-READ-SORT.          

The code appears to fine in the 'OUTPUT' procedure, and the return is in the correct place,

P2000-READ-SORT.                                                  RETURN SORT-FILE                                                AT END                                                               PERFORM P2100-UPDATE-SAVE-RECORD THRU P2199-EXIT              GO TO P2199-EXIT.                               

This code apparently ran fine on a Mainframe.  I'm on a project to convert all applications to the i.  Any help or suggestions would be appreciated.

Thank you



Software/Hardware used:
AS/400 iSeries version 6.1
ASKED: September 10, 2009  8:44 PM
UPDATED: September 17, 2009  7:47 PM

Answer Wiki:
It ran fine on the mainframe. Now you are converting it to the "i" but where is the program running? Is it still running on the mainframe? Or has the code been compiled and executed on some other platform and operating system? You are getting this error during COMPILE; right? IF you have taken the source code from the mainframe and copied to some other box and are trying to compile in a new environment, you need to ensure that you are following the rules for COBOL in this new environment. Not all COBOLs are the same. Each compiler has its own rules. Just like SQL for DB2 is different than SQL for Oracle. IBM COBOL on the mainframe is different from NetCOBOL for Windows. So check the syntax of this PC version of COBOL internal SORT.
Last Wiki Answer Submitted:  September 11, 2009  2:04 pm  by  Meandyou   5,205 pts.
All Answer Wiki Contributors:  Meandyou   5,205 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

The program has been imported to the i, and necessary changes have been made for the new environment.
The program has compiled on the i, the error is occuring on execution.
We have several programs with the the same ‘internal sort’ logic that are running fine on the i.
It’s very strange.
IBM doesn’t offer information as far as the error goes.

 145 pts.

 

Interesting. I assume that some changes to the source code were required when you moved it to the i. (By the way, what is “the i?”) Is it possible the the RETURN is being executed out of sequence? A stray branch instruction, perhaps, is causing it to be executed before it should be (or executed twice)?

Other than that, I don’t know what to suggest.

 5,205 pts.

 

After further investigation there were changes made to the source. I re-imported the original code and recompiled and there is no longer an issue.
BTW, an i is the same as the iSeries or AS/400.
I appreciate your input.
Thanks.

 145 pts.

 

Hey, glad you found it.

 5,205 pts.