我試圖搜索一個表,但它保持結局。我對COBOL很陌生,我不確定我是否犯了一個簡單的錯誤。當我嘗試調試時,它看起來好像教區代碼匹配,所以我不確定它爲什麼不輸出領土代碼。這個例程的說明和我的代碼在以下情況下有幫助。我知道我錯過了很多(如計數),但我只是想先獲得一些輸出。任何幫助,將不勝感激!COBOL搜索功能
閱讀每條記錄。如果記錄類型爲94,則使用SEARCH動詞在教區/地區表中查找教區代碼並查找地區代碼。將地區代碼添加到輸出記錄並將記錄寫入磁盤。
如果在教區/地區表中找到教區,請在地區表中增加該地區的計數。
如果教區不在教區/地區表中,則將該程序異常終止。
將每個地區和該地區相應的政策數量打印到報告中。
打印處理的總記錄數和總處理報告的策略數。
FILE SECTION. FD REPORT-FILE LABEL RECORDS ARE OMITTED DATA RECORD IS REPORT-RECORD. 01 REPORT-RECORD PIC X(132). FD PRINT-FILE LABEL RECORDS ARE OMITTED DATA RECORD IS PRINT-RECORD. 01 PRINT-RECORD PIC X(132). FD INPUT-FILE LABEL RECORD IS STANDARD. COPY TRNREC94. EJECT WORKING-STORAGE SECTION. 01 record-ws. 05 rec-record-type pic x(2) read input-file 05 rec-policy-number pic x(8) 05 filler pic x(5) 05 rec-parish-code pic x(3) 05 filler pic x(1) 05 rec-territory-code pic x(1) 05 filler pic x(60) 01 HEADER. 05 FILLER PIC X(8) VALUE 'TSTHC020'. 05 FILLER PIC X(30) VALUE SPACES. 05 FILLER PIC X(41) VALUE 'LOUISIANA FARM BUREAU INSURANCE COMPANIES'. 05 FILLER PIC X(30) VALUE SPACES. 05 FILLER PIC X(5) VALUE 'PAGE '. 05 PRINT-PAGE-NUMBER PIC ZZZZZZ9. 01 HEADER-LINE-2. 05 FILLER PIC X(10) VALUE '10/22/2013'. 01 DETAIL-LINE. 05 DET-TERRITORY PIC X(2). 05 DET-NUMBER-POLICIES PIC X(2). 01 COLUMN-LINE. 05 FILLER PIC X(9) VALUE 'TERRITORY'. 05 FILLER PIC X(10) VALUE SPACES. 05 FILLER PIC X(18) VALUE 'NUMBER OF POLICIES'. 01 TOTAL-LINE. 05 FILLER PIC X(26) VALUE 'TOTAL RECORDS PROCESSED IS'. 05 TOTAL-RECORDS PIC X(3). 05 FILER PIC X(32) VALUE 'AND TOTAL POLICIES PROCESSED IS'. 05 TOTAL-POLICIES PIC X(3). 01 PROG-ID. 05 FILLER PIC X(50) VALUE 'PROGRAM - TSTXX002- WORKING STORAGE STARTS HERE'. 01 MISC-VARIABLES-SW. 05 END-OF-FILE-SW PIC XXX. 88 ALL-RECORDS-ARE-PROCESSED VALUE 'YES'. 88 MORE-RECORDS VALUE 'NO'. 01 FILE-STATUS-VALUES. 05 FILE-STATUS PIC 99. 88 SUCCESSFUL-READ VALUE 0. 88 SUCCESSFUL-START VALUE 0. 88 SUCCESSFUL-WRITE VALUE 0. 88 SUCCESSFUL-DELETE VALUE 0. 88 SUCCESSFUL-OPEN VALUE 0. 88 SUCCESSFUL-CLOSE VALUE 0. 88 END-OF-FILE VALUE 10. 88 RECORD-NOT-FOUND VALUE 23. 05 PAGE-CONTROLLERS. 10 A-LINE-COUNT PIC 999 COMP-3 VALUE 0. 10 A-PAGE-COUNT PIC 999 COMP-3 VALUE 0. 10 A-DISK-COUNTER PIC 9(5) COMP-3 VALUE 0. 01 TABLES. 05 T1-TERRITORY-VALUES. 10 FILLER PIC X(4) VALUE '0101'. 10 FILLER PIC X(4) VALUE '0207'. 10 FILLER PIC X(4) VALUE '0307'. 10 FILLER PIC X(4) VALUE '0409'. 10 FILLER PIC X(4) VALUE '0509'. 10 FILLER PIC X(4) VALUE '0609'. 10 FILLER PIC X(4) VALUE '0709'. 10 FILLER PIC X(4) VALUE '0801'. 10 FILLER PIC X(4) VALUE '0901'. 10 FILLER PIC X(4) VALUE '1001'. 10 FILLER PIC X(4) VALUE '1104'. 10 FILLER PIC X(4) VALUE '1204'. 10 FILLER PIC X(4) VALUE '1305'. 10 FILLER PIC X(4) VALUE '1405'. 10 FILLER PIC X(4) VALUE '1506'. 10 FILLER PIC X(4) VALUE '1606'. 10 FILLER PIC X(4) VALUE '1707'. 10 FILLER PIC X(4) VALUE '1802'. 10 FILLER PIC X(4) VALUE '1902'. 10 FILLER PIC X(4) VALUE '2002'. 10 FILLER PIC X(4) VALUE '2103'. 10 FILLER PIC X(4) VALUE '2208'. 10 FILLER PIC X(4) VALUE '2308'. 10 FILLER PIC X(4) VALUE '2409'. 10 FILLER PIC X(4) VALUE '2506'. 10 FILLER PIC X(4) VALUE '2605'. 10 FILLER PIC X(4) VALUE '2704'. 10 FILLER PIC X(4) VALUE '2804'. 10 FILLER PIC X(4) VALUE '2903'. 10 FILLER PIC X(4) VALUE '3003'. 05 T1-TERRITORY-TABLE REDEFINES T1-TERRITORY-VALUES. 10 T1-ENTRY OCCURS 30 TIMES INDEXED BY T1-INDEX. 15 T1-PARISH PIC XXX. 15 T1-TERRITORY PIC X. 05 T2-TERRITORY-COUNT. 10 FILLER PIC X(4) VALUE '1 '. 10 FILLER PIC X(4) VALUE '2 '. 10 FILLER PIC X(4) VALUE '3 '. 10 FILLER PIC X(4) VALUE '4 '. 10 FILLER PIC X(4) VALUE '5 '. 10 FILLER PIC X(4) VALUE '6 '. 10 FILLER PIC X(4) VALUE '7 '. 10 FILLER PIC X(4) VALUE '8 '. 10 FILLER PIC X(4) VALUE '9 '. 05 T2-TERRITORY-TABLE REDEFINES T2-TERRITORY-COUNT. 10 T2-ENTRY OCCURS 9 TIMES INDEXED BY T2-INDEX. 15 T2-TERRITORY-CODE PIC X. 15 T2-TERRITORY-COUNTER PIC XXX. PROCEDURE DIVISION. A000-MAINLINE. PERFORM B000-OPENING-PROCEDURE. PERFORM B110-PRINT-HEADINGS. PERFORM B300-READ-FILE. PERFORM B500-MAIN-PROCEDURE UNTIL END-OF-FILE-SW = 'YES'. PERFORM B100-CLOSING-PROCEDURE. STOP RUN. B000-OPENING-PROCEDURE. OPEN OUTPUT REPORT-FILE. OPEN OUTPUT PRINT-FILE. OPEN I-O INPUT-FILE. B100-CLOSING-PROCEDURE. PERFORM B800-PRINT-TOTAL-LINE. CLOSE REPORT-FILE. CLOSE PRINT-FILE. CLOSE INPUT-FILE. B200-PRINT-HEADER. MOVE HEADER TO PRINT-RECORD. WRITE PRINT-RECORD. MOVE HEADER-LINE-2 TO PRINT-RECORD. WRITE PRINT-RECORD BEFORE ADVANCING 1. B300-READ-FILE. READ INPUT-FILE NEXT RECORD AT END MOVE 'YES' TO END-OF-FILE-SW. B500-MAIN-PROCEDURE. PERFORM B600-SEARCH-TERRITORY PERFORM B300-READ-FILE. B600-SEARCH-TERRITORY. SET T1-INDEX TO 1. SEARCH T1-ENTRY AT END DISPLAY 'PARISH NOT FOUND IN TABLE' CALL 'CEE3ABD' USING BY VALUE 12 BY VALUE 1 WHEN REC-94-PARISH-CODE = T1-PARISH(T1-INDEX) MOVE T1-TERRITORY(T1-INDEX) TO DET-TERRITORY. B700-PRINT-DETAIL-LINE. MOVE DETAIL-LINE TO PRINT-RECORD. WRITE PRINT-RECORD BEFORE ADVANCING 1. B800-PRINT-TOTAL-LINE. MOVE A-LINE-COUNT TO TOTAL-RECORDS. MOVE TOTAL-LINE TO PRINT-RECORD. WRITE PRINT-RECORD AFTER ADVANCING 1. B900-PRINT-COLUMN-LINE. MOVE COLUMN-LINE TO PRINT-RECORD. WRITE PRINT-RECORD BEFORE ADVANCING 1. B110-PRINT-HEADINGS. ADD 1 TO A-PAGE-COUNT. MOVE A-PAGE-COUNT TO PRINT-PAGE-NUMBER. PERFORM B200-PRINT-HEADER. PERFORM B900-PRINT-COLUMN-LINE.
什麼是您的抄寫本中REC-94-PARISH-CODE的定義?您也沒有任何東西來檢查類型94.如果您有其他記錄類型,他們是否有教區代碼在同一位置?如果沒有,並且在94條記錄之前還有另一種記錄類型,則不會得到一個匹配(除非您不幸),並且您會得到您的結尾。 –
COPYBOOK:TRNREC94 01 RECORD-TYPE-94。 05 REC-94-TYPE PIC X(2)。 05 REC-94-POLICY-NUMBER PIC X(8)。 (5)。FILLER PIC X(5)。 05 REC-94-PARISH-CODE PIC X(3)。 05 FILLER PIC X(1)。 05 REC-94-TERRITORY-CODE PIC X(1)。 FILLER PIC X(60)。 其他記錄類型沒有教區代碼在我認爲相同的位置。我不確定抄本是如何工作的,這就是爲什麼我沒有檢查類型94的原因,我認爲複製記錄94就足夠了。 – Meg