我正在尝试搜索一个表,但它一直在异常。我对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.
答案 0 :(得分:2)
它认为你的问题在于没有测试94s。仅仅包含一本字帖是不够的。
B500-MAIN-PROCEDURE.
IF REC-94-TYPE EQUAL TO "94"
PERFORM B600-SEARCH-TERRITORY
END-IF
PERFORM B300-READ-FILE
.
理想情况下,您可以在记录类型中使用88,您可以在同一文件的另一个副本中找到它。
请注意,在段落/ SECTION开始或程序结束之前,我使用了范围分隔符(END-IF)并将句点/句号的数量限制为强制格式。
你正在做IO,你甚至设置了88s,但是你没有对IO进行任何状态检查。你应该。总是
为什么要打开I-O的输入?如果您有一个普通的顺序文件,请阅读它并写一个新文件。否则,您必须在程序运行之前创建备份。如果不这样做,那么就地更新就会变得非常糟糕。