Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting a work file

Status
Not open for further replies.

jmanj

Programmer
May 20, 2003
298
0
0
US
I'm sorting a work file and it seems to be okay except at the
very end(I think) I'm getting this message. Hope somebody can help: Bad File Status 4 1 On File SORTEDFILE

Here's my sort statement:
SD SORT-FILE.
01 SORT-REC.
SSN
etc etc etc

OPEN OUTPUT SORTEDFILE.

SORT SORT-FILE
ON ASCENDING KEY SSN OF SORT-REC
INPUT PROCEDURE 1000-DO-GET-DATA
GIVING SORTEDFILE.

CLOSE SORTEDFILE.

1000-DO-GET-DATA.
Procedures here to get data and move to DETAIL-REC.


here my release: RELEASE SORT-REC FROM DETAIL-REC

Thanks.
 
I've never seen that message, but when using the SORT with the GIVING option in IBM COBOL, you do not open and close the output file. SORT takes care of the opening and closing of the file.
 
Kenny's right. The file status error you are getting says that you are trying to open a file that is already open.

Cathy
 
Kenny, Cathy,

You are all absolutely right!!! How could I missed it. I copied the logic from an old cobol program(I Don't have any book) I found in one of my old tapes and improvised it. I did'nt realized I was opening a sort output file. Everything went fine after I remove the open/close statement of the work file. The resulting sort was perfect.

I think I really need to buy me a book on cobol stuff. I just cannot trust myself anymore with this kind job. twenty years ago I could remember all the whizzes and bangs of Cobol, but that was when my brain together with youth were functioning
perfectly in conjunction with the programming world.

Thank you all very much. I really appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top