我需要根据地区代码找出每个地区有多少政策。所以每次我在记录中找到区域时,我都需要在我的表中增加该区域的计数,然后我才能将它移动到我的输出中。根据下面的记录,我无法弄清楚如何计算每个地区的政策。我尝试了各种方法,但似乎没有任何效果。
如果您需要更多信息,请告诉我。
以下是记录的定义和摘录(共 57 条记录)
rec-94 型图片 x(2) rec-94-policy-number pic x(8) 填充图片 x(5) rec-94-parish-code pic x(3) 填充图片 x(1) rec-94 区域代码 pic x(1) 94A 018517 080 1 94A 027721 090 1 94A 036470 250 6 94A 049137 010 1 ……
我最近的尝试:
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 999.
A000-MAINLINE.
PERFORM B000-OPENING-PROCEDURE.
PERFORM B600-PRINT-HEADINGS.
PERFORM B200-READ-FILE.
PERFORM B300-MAIN-PROCEDURE
UNTIL END-OF-FILE-SW = 'YES'.
PERFORM B800-MOVE-TERRITORY-CODE
VARYING T2-INDEX FROM 1 BY 1
UNTIL T2-INDEX > 9.
PERFORM B110-MOVE-COUNTS
PERFORM B100-CLOSING-PROCEDURE.
STOP RUN.
B000-OPENING-PROCEDURE.
OPEN OUTPUT REPORT-FILE.
OPEN OUTPUT PRINT-FILE.
OPEN INPUT INPUT-FILE.
B100-CLOSING-PROCEDURE.
PERFORM B500-PRINT-TOTAL-LINE.
CLOSE REPORT-FILE.
CLOSE PRINT-FILE.
CLOSE INPUT-FILE.
B200-READ-FILE.
READ INPUT-FILE INTO RECORD-TYPE-94
AT END MOVE 'YES' TO END-OF-FILE-SW.
B300-MAIN-PROCEDURE.
IF REC-94-TYPE = "94"
PERFORM B400-SEARCH-TERRITORY
PERFORM B900-COUNT-POLICIES
ELSE
WRITE REPORT-RECORD FROM RECORD-TYPE-94
END-IF.
ADD 1 TO A-LINE-COUNT.
PERFORM B200-READ-FILE.
B400-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
REC-94-TERRITORY-CODE
ADD 1 TO A-DISK-COUNTER
PERFORM B700-MOVE-RECORDS
END-SEARCH.
B500-PRINT-TOTAL-LINE.
MOVE A-LINE-COUNT TO TOTAL-RECORDS.
MOVE A-DISK-COUNTER TO TOTAL-POLICIES.
WRITE PRINT-RECORD FROM TOTAL-LINE.
B600-PRINT-HEADINGS.
ADD 1 TO A-PAGE-COUNT.
MOVE A-PAGE-COUNT TO PRINT-PAGE-NUMBER.
WRITE PRINT-RECORD FROM HEADER.
WRITE PRINT-RECORD FROM HEADER-LINE-2.
WRITE PRINT-RECORD FROM COLUMN-LINE.
B700-MOVE-RECORDS.
MOVE REC-94-TYPE TO REC-94-TYPE-OUT
MOVE REC-94-POLICY-NUMBER TO REC-94-POLICY-NUMBER-OUT
MOVE REC-94-PARISH-CODE TO REC-94-PARISH-CODE-OUT
MOVE REC-94-TERRITORY-CODE TO REC-94-TERRITORY-CODE-OUT
WRITE REPORT-RECORD FROM TRNREC94-OUT.
B800-MOVE-TERRITORY-CODE.
MOVE T2-TERRITORY-CODE(T2-INDEX) TO DET-TERRITORY.
WRITE PRINT-RECORD FROM DETAIL-LINE.
B900-COUNT-POLICIES.
MOVE ZEROES TO T2-TERRITORY-COUNTER(T2-INDEX).
SET T2-INDEX TO 1.
SEARCH T2-ENTRY
AT END
DISPLAY 'NO POLICIES FOUND.'
WHEN
REC-94-TERRITORY-CODE =
T2-TERRITORY-CODE(T2-INDEX)
ADD 1 TO T2-TERRITORY-COUNTER(T2-INDEX)
END-SEARCH.
MOVE T2-TERRITORY-COUNTER(T2-INDEX) TO DET-NUMBER-POLICIES.
WRITE PRINT-RECORD FROM DETAIL-LINE.
我将不胜感激任何指示或正确的方向。在此先感谢!
我的最终代码:
PERFORM B000-OPENING-PROCEDURE.
PERFORM B600-PRINT-HEADINGS.
PERFORM B200-READ-FILE.
PERFORM B300-MAIN-PROCEDURE
UNTIL END-OF-FILE-SW = 'YES'.
PERFORM C100-MOVE-COUNTS
VARYING T2-INDEX FROM 1 BY 1
UNTIL T2-INDEX > 9.
PERFORM B100-CLOSING-PROCEDURE.
STOP RUN.
B000-OPENING-PROCEDURE.
OPEN OUTPUT REPORT-FILE.
OPEN OUTPUT PRINT-FILE.
OPEN INPUT INPUT-FILE.
B100-CLOSING-PROCEDURE.
PERFORM B500-PRINT-TOTAL-LINE.
CLOSE REPORT-FILE.
CLOSE PRINT-FILE.
CLOSE INPUT-FILE.
B200-READ-FILE.
READ INPUT-FILE INTO RECORD-TYPE-94
AT END MOVE 'YES' TO END-OF-FILE-SW.
B300-MAIN-PROCEDURE.
IF REC-94-TYPE = "94"
PERFORM B400-SEARCH-TERRITORY
ELSE
WRITE REPORT-RECORD FROM RECORD-TYPE-94
END-IF.
ADD 1 TO A-LINE-COUNT.
PERFORM B200-READ-FILE.
B400-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
REC-94-TERRITORY-CODE
ADD 1 TO A-DISK-COUNTER
PERFORM B700-MOVE-RECORDS
PERFORM B900-COUNT-POLICIES
END-SEARCH.
B500-PRINT-TOTAL-LINE.
MOVE A-LINE-COUNT TO TOTAL-RECORDS.
MOVE A-DISK-COUNTER TO TOTAL-POLICIES.
WRITE PRINT-RECORD FROM TOTAL-LINE.
B600-PRINT-HEADINGS.
ADD 1 TO A-PAGE-COUNT.
MOVE A-PAGE-COUNT TO PRINT-PAGE-NUMBER.
WRITE PRINT-RECORD FROM HEADER.
WRITE PRINT-RECORD FROM HEADER-LINE-2.
WRITE PRINT-RECORD FROM COLUMN-LINE.
B700-MOVE-RECORDS.
MOVE REC-94-TYPE TO REC-94-TYPE-OUT
MOVE REC-94-POLICY-NUMBER TO REC-94-POLICY-NUMBER-OUT
MOVE REC-94-PARISH-CODE TO REC-94-PARISH-CODE-OUT
MOVE REC-94-TERRITORY-CODE TO REC-94-TERRITORY-CODE-OUT
WRITE REPORT-RECORD FROM TRNREC94-OUT.
B900-COUNT-POLICIES.
SET T2-INDEX TO 1.
SEARCH T2-ENTRY
AT END
DISPLAY 'NO POLICIES FOUND.'
WHEN
REC-94-TERRITORY-CODE = T2-TERRITORY-CODE(T2-INDEX)
DD 1 TO T2-TERRITORY-COUNTER(T2-INDEX)
END-SEARCH.
C100-MOVE-COUNTS.
MOVE T2-TERRITORY-CODE(T2-INDEX) TO DET-TERRITORY.
MOVE T2-TERRITORY-COUNTER(T2-INDEX) TO DET-NUMBER-POLICIES.
WRITE PRINT-RECORD FROM DETAIL-LINE.