I have a huge problem in a program revolving around reading an indexed file. While the program involves two other reads that work just fine this one keeps giving me problems. Here is the code for everything that involves it:
SELECT PO-MASTER-FILE
ASSIGN TO 'PO-INDEXED.DAT'
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD KEY IS PO-KEY
FILE STATUS IS FILE-STATUS-CODE.
DATA DIVISION.
FILE SECTION.
FD PO-MASTER-FILE.
01 PO-MASTER-RECORD.
05 PO-KEY.
10 PO-VEND-NUMBER-M PIC X(4).
10 PO-ORDER-ID-M PIC X(8).
WORKING-STORAGE SECTION.
05 PO-KEY-S.
10 POLI-VEND-NUMBER-S PIC X(4).
10 POLI-ORDER-ID-S PIC X(8).
SCREEN SECTION.
05 LINE 07 COLUMN 23 VALUE 'NUMBER:'
FOREGROUND-COLOR 10.
05 LINE 07 COLUMN 50 PIC X(4)
USING POLI-VEND-NUMBER-S
FOREGROUND-COLOR 15 AUTO.
05 LINE 08 COLUMN 23 VALUE 'ORDER ID:'
FOREGROUND-COLOR 10.
05 LINE 08 COLUMN 50 PIC X(8)
USING POLI-ORDER-ID-S
FOREGROUND-COLOR 15 AUTO.
PROCEDURE DIVISION.
100-MAIN.
OPEN I-O POLI-MASTER-FILE
PO-MASTER-FILE
ITEM-MASTER-FILE
PERFORM 120-DISPLAY-SCREEN
UNTIL FUNCTION-CODE-S = 'END' OR 'end'
CLOSE POLI-MASTER-FILE
PO-MASTER-FILE
ITEM-MASTER-FILE
EXIT PROGRAM
STOP RUN.
120-DISPLAY-SCREEN.
****
MOVE FUNCTION-CODE-S TO SAVE-FUNCTION-CODE
****
MOVE POLI-VEND-NUMBER-S TO SAVE-VEND-NUMBER
****
CALL 'DATETIME' USING DATE-TIME-PASS-AREA
DISPLAY SCREEN-IMAGE
ACCEPT SCREEN-IMAGE
IF FUNCTION-CODE-S = 'END' OR 'end'
CONTINUE
ELSE
PERFORM 200-PROCESS
END-IF.
200-PROCESS.
MOVE SPACES TO ERROR-MESSAGE-S
EVALUATE TRUE
WHEN FUNCTION-CODE-S = 'INQ' OR 'inq'
PERFORM 300-INQUIRY
WHEN FUNCTION-CODE-S = 'ADD' OR 'add'
PERFORM 400-ADD
WHEN FUNCTION-CODE-S = 'CHG' OR 'chg'
PERFORM 500-CHANGE
WHEN FUNCTION-CODE-S = 'DEL' OR 'del'
PERFORM 600-DELETE
WHEN OTHER
MOVE 'Invalid Function Code' TO ERROR-MESSAGE-S
END-EVALUATE.
400-ADD.
****
PERFORM 900-VALIDATE-THE-FIELDS THRU 999-EXIT
IF ERROR-MESSAGE-S = SPACES
PERFORM 420-OK-TO-ADD-THE-RECORD
ELSE
****
MOVE SPACES TO POLI-DATE-ADDED-S
END-IF.
900-VALIDATE-THE-FIELDS.
MOVE PO-KEY-S TO PO-KEY
READ PO-MASTER-FILE
INVALID KEY
IF FILE-STATUS-CODE = '23'
开发者_如何学JAVA MOVE 'Vendor Number Or Order ID Is Not Found'
TO ERROR-MESSAGE-S
GO TO 999-EXIT
ELSE
MOVE FILE-STATUS-CODE TO UNEXPECTED-CODE
MOVE UNEXPECTED-CODE TO ERROR-MESSAGE-S
END-IF
END-READ
There is more validation code after this point and the program skips right over this part as if it finds a file even if I leave POLI-VEND-NUMBER-S
and POLI-ORDER-ID-S
blank on the screen. I am a bit stumped to say the least. Any help will be appreciated. Thank you for your time.
Ok, I figured out the problem. It seems that I left out some fields that were in the indexed file because they were not needed in this part of the program. As a result the record would not load and (For some reason) the read was skipped. Basically this is what was missing:
FD PO-MASTER-FILE.
01 PO-MASTER-RECORD.
05 PO-KEY.
10 PO-VEND-NUMBER-M PIC X(4).
10 PO-ORDER-ID-M PIC X(8).
05 PO-DATE-ADDED-M.
10 PO-DA-YEAR-M PIC X(4).
10 PO-DA-MONTH-M PIC XX.
10 PO-DA-DAY-M PIC XX.
Thanks to anyone who looked at this and tried to help.
精彩评论