Merge Statement (COBOL)
I was working on a program that needed to use a merge statement to put two files together and sort them. Of course though I would not be here if I didn't have a problem. When I run my program I have to do a little work afterward to add to the output. When it it goes to perform that paragraph it gives an error that says "Merge File out of sequences ORDER-FILE-SOR". Here is my code:
100-MAIN.
MERGE ORDERS-FILE-SORT
ON ASCENDING KEY REQUEST-DATE-S
ON ASCENDING KEY CUST-NUMBER-S
ON ASCENDING KEY CUST-ORDER-NUMBER-S
ON ASCENDING KEY PART-NUMBER-S
USING ORDERS-FILE-PRIOR-IN
ORDERS-FILE-NEW-IN
OUTPUT PROCEDURE 200-FILE-START
STOP RUN.
200-FILE-START.
OPEN OUTPUT ORDERS-FILE-OUT
ACCEPT WS-DATE FROM DATE
MOVE RUN-MONTH TO MONTH-1
MOVE R开发者_如何学JAVAUN-DAY TO DAY-1
MOVE RUN-YEAR TO YEAR-1
PERFORM 300-NEXT-PAGE
PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO '
RETURN ORDERS-FILE-SORT
AT END
MOVE 'NO ' TO ARE-THERE-MORE-RECORDS
NOT AT END
PERFORM 400-PROCESS-FILE
END-RETURN
END-PERFORM.
CLOSE ORDERS-FILE-OUT.
The output it does show is the heading line and it seems to stop at the "RETURN ORDERS-FILE-SORT" line.
Any help would be greatly appreciated as I feel the rest of the program will run just fine, but I can't check it till this is fixed.
The MERGE verb combines two or more identically sequenced files. To have it work, you must have already sorted them according to an identical set of ascending/descending keys.
If your input is not already in that order, you might need to sort each file by REQUEST-DATE-S, CUST-NUMBER-S, CUST-ORDER-NUMBER-S and PART-NUMBER-S
精彩评论