我的输出不正确,我不太确定如何进行二维数组。
我的输出后面跟着输出应该看起来像.....
如何设置二维表的好例子会有所帮助,因为我不确定我在网上找到的东西是否好,而且还没有找到一本足够好的书来向老人解释条款。
首先是我的代码:
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO DATAIN
ORGANIZATION IS LINE SEQUENTIAL.
SELECT OUTPUT-FILE ASSIGN TO DATAOUT
ORGANIZATION IS LINE SEQUENTIAL.
SELECT ERROR-FILE ASSIGN TO DATAOUT2
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
*-------------------------------------------------------------*
* INPUT FILE LAYOUT *
*-------------------------------------------------------------*
FD INPUT-FILE.
01 INPUT-RECORD.
05 IR-JOB-NUM PIC 9(02).
88 IR-JOB-NUM-VALID VALUE 01 THRU 11.
05 IR-EMP-NUM PIC 9(01).
88 IR-EMP-NUM-VALID VALUE 1 THRU 4.
05 IR-NUM-COMPLETE PIC 9(04).
05 FILLER PIC X(03).
05 FILLER PIC X(07).
*-------------------------------------------------------------*
* OUTPUT FILE *
*-------------------------------------------------------------*
FD OUTPUT-FILE.
01 OUTPUT-RECORD PIC X(80).
*-------------------------------------------------------------*
* ERROR FILE *
*-------------------------------------------------------------*
FD ERROR-FILE.
01 ERROR-RECORD PIC X(80).
*-------------------------------------------------------------*
* WORKING STORAGE SECTION *
*-------------------------------------------------------------*
WORKING-STORAGE SECTION.
01 FLAGS-AND-ACCUMALATORS.
05 END-OF-FILE PIC XXX VALUE "NO".
88 AT-END-OF-FILE VALUE "YES".
05 ERROR-FLAG PIC XXX VALUE "NO".
05 BLANK-LINE PIC X(80) VALUE SPACES.
05 LINE-NUM-IR-POSITION PIC 999 VALUE ZERO.
01 SUBSCRIPT.
05 SUB PIC 99 VALUE ZERO.
*---------------------------------------------------------------*
* REPORT STRUCTURE *
*---------------------------------------------------------------*
* ERROR HEADER RECORD *
01 ER-HEADER.
05 FILLER PIC X(08) VALUE SPACES.
05 FILLER PIC X(03) VALUE "NO.".
05 FILLER PIC X(10) VALUE SPACES.
05 FILLER PIC X(06) VALUE "RECORD".
05 FILLER PIC X(15) VALUE SPACES.
05 FILLER PIC X(05) VALUE "ABOVE".
05 FILLER PIC X(33) VALUE SPACES.
* ERROR DETAIL RECORD *
01 ER-DETAIL-LINE.
05 FILLER PIC X(06) VALUE SPACES.
05 DL-ASTERIK PIC X(01) VALUE SPACES.
05 FILLER PIC X(01) VALUE SPACES.
05 DL-LINE-NUM PIC ZZ9 VALUE SPACES.
05 FILLER PIC X(09) VALUE SPACES.
05 DL-ERROR PIC X(16) VALUE SPACES.
05 FILLER PIC X(09) VALUE SPACES.
05 DL-ERROR-BIG-NUM PIC ZZZ9 VALUE SPACES.
* ERROR ERROR RECORD *
01 ER-ERROR-LINE.
05 FILLER PIC X(20) VALUE SPACES.
05 EL-JOB-NUM PIC X(02) VALUE SPACES.
05 EL-EMP-NUM PIC X(01) VALUE SPACES.
05 EL-NUM-COMPLETE PIC X(03) VALUE SPACES.
05 FILLER PIC X(54) VALUE SPACES.
* OUTPUT HEADER RECORD *
01 OR-HEADER.
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(03) VALUE "NO.".
05 FILLER PIC X(02) VALUE SPACES.
05 FILLER PIC X(08) VALUE "LOCATION".
05 FILLER PIC X(03) VALUE SPACES.
05 FILLER PIC X(05) VALUE " 1 ".
05 FILLER PIC X(03) VALUE SPACES.
05 FILLER PIC X(05) VALUE " 2 ".
05 FILLER PIC X(03) VALUE SPACES.
05 FILLER PIC X(05) VALUE " 3 ".
05 FILLER PIC X(03) VALUE SPACES.
05 FILLER PIC X(05) VALUE " 4 ".
05 FILLER PIC X(03) VALUE SPACES.
05 FILLER PIC X(05) VALUE "TOTAL".
05 FILLER PIC X(15) VALUE SPACES.
* OUTPUT DETAIL RECORD *
01 OR-DETAIL-LINE.
03 OR-DETAIL OCCURS 11 TIMES.
05 FILLER PIC X(02) VALUE SPACES.
05 OR-JOB-NUM PIC 9(02).
05 FILLER PIC X(03) VALUE SPACES.
05 OR-LOCATION PIC X(08) VALUE "XXXXXXXX".
05 FILLER PIC X(03) VALUE SPACES.
05 OR-EMP1-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-EMP2-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-EMP3-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-EMP4-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-JOB-TOT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(15) VALUE SPACES.
* SUMMARY RECORD *
01 OR-SUMMARY.
05 FILLER PIC X(08) VALUE SPACES.
05 FILLER PIC X(06)
VALUE "TOTALS".
05 FILLER PIC X(04) VALUE SPACES.
05 OR-TOT1-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-TOT2-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-TOT3-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-TOT4-AMT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(03) VALUE SPACES.
05 OR-TOT-TOT PIC 9(05) VALUE ZEROES.
05 FILLER PIC X(15) VALUE SPACES.
PROCEDURE DIVISION.
*****************************************************************
*0000-MAIN-PROCEDURE *
*****************************************************************
0000-MAIN-PROCEDURE SECTION.
OPEN INPUT INPUT-FILE
OUTPUT OUTPUT-FILE
ERROR-FILE.
PERFORM 1000-INITIALIZE.
PERFORM UNTIL AT-END-OF-FILE
READ INPUT-FILE
AT END
MOVE 'YES' TO END-OF-FILE
NOT AT END
PERFORM 2000-PROCESS
END-READ
END-PERFORM.
PERFORM VARYING SUB FROM 1 BY 1 UNTIL SUB > 11
PERFORM 3000-FINALIZE
END-PERFORM.
PERFORM 4000-SUMMARY.
CLOSE INPUT-FILE
OUTPUT-FILE
ERROR-FILE.
GOBACK.
0000-EXIT.
EXIT.
/
*****************************************************************
*1000-INITIALIZE *
*****************************************************************
*PURPOSE: INITIALIZE ALL THE VARIABLES AND *
* WRITE THE HEADER RECORDS TO THE OUTPUT FILES. *
*****************************************************************
1000-INITIALIZE SECTION.
WRITE ERROR-RECORD FROM ER-HEADER.
WRITE ERROR-RECORD FROM BLANK-LINE.
WRITE OUTPUT-RECORD FROM OR-HEADER.
WRITE OUTPUT-RECORD FROM BLANK-LINE.
1000-EXIT.
EXIT.
/
2000-PROCESS SECTION.
*****************************************************************
*PURPOSE: *
*****************************************************************
MOVE 'NO' TO ERROR-FLAG.
ADD 1 TO LINE-NUM-IR-POSITION.
IF NOT IR-JOB-NUM-VALID
MOVE INPUT-RECORD TO DL-ERROR
MOVE LINE-NUM-IR-POSITION
TO DL-LINE-NUM
MOVE 'YES' TO ERROR-FLAG
MOVE ALL '*' TO EL-JOB-NUM
END-IF.
IF NOT IR-EMP-NUM-VALID
MOVE INPUT-RECORD TO DL-ERROR
MOVE LINE-NUM-IR-POSITION
TO DL-LINE-NUM
MOVE 'YES' TO ERROR-FLAG
MOVE ALL '*' TO EL-EMP-NUM
END-IF.
IF ERROR-FLAG = 'NO'
INSPECT IR-NUM-COMPLETE REPLACING LEADING
SPACES BY ZEROES
IF IR-NUM-COMPLETE IS NUMERIC
MOVE IR-JOB-NUM TO SUB
IF IR-EMP-NUM = 1
ADD IR-NUM-COMPLETE TO
OR-EMP1-AMT(SUB)
END-IF
IF IR-EMP-NUM = 2
ADD IR-NUM-COMPLETE TO
OR-EMP2-AMT(SUB)
END-IF
IF IR-EMP-NUM = 3
ADD IR-NUM-COMPLETE TO
OR-EMP3-AMT(SUB)
END-IF
IF IR-EMP-NUM = 4
ADD IR-NUM-COMPLETE TO
OR-EMP4-AMT(SUB)
END-IF
ELSE
MOVE INPUT-RECORD TO DL-ERROR
MOVE LINE-NUM-IR-POSITION
TO DL-LINE-NUM
MOVE 'YES' TO ERROR-FLAG
MOVE ALL '*' TO EL-NUM-COMPLETE
END-IF.
IF ERROR-FLAG = 'YES'
IF IR-NUM-COMPLETE > 50
MOVE ALL '*' TO DL-ASTERIK
MOVE IR-NUM-COMPLETE TO DL-ERROR-BIG-NUM
END-IF
WRITE ERROR-RECORD FROM ER-DETAIL-LINE
WRITE ERROR-RECORD FROM ER-ERROR-LINE
MOVE SPACES TO ER-DETAIL-LINE
MOVE SPACES TO ER-ERROR-LINE
END-IF.
2000-EXIT.
EXIT.
/
3000-FINALIZE SECTION.
*****************************************************************
*PURPOSE: *
*****************************************************************
MOVE SUB TO OR-JOB-NUM(SUB).
ADD OR-EMP1-AMT(SUB)
OR-EMP2-AMT(SUB)
OR-EMP3-AMT(SUB)
TO OR-EMP4-AMT(SUB)
GIVING OR-JOB-TOT(SUB).
ADD OR-EMP1-AMT(SUB) TO OR-TOT1-AMT.
ADD OR-EMP2-AMT(SUB) TO OR-TOT2-AMT.
ADD OR-EMP3-AMT(SUB) TO OR-TOT3-AMT.
ADD OR-EMP4-AMT(SUB) TO OR-TOT4-AMT.
ADD OR-JOB-TOT(SUB) TO OR-TOT-TOT.
IF OR-JOB-TOT(SUB) > 0
WRITE OUTPUT-RECORD FROM OR-DETAIL(SUB)
WRITE OUTPUT-RECORD FROM BLANK-LINE
END-IF.
3000-EXIT.
EXIT.
/
4000-SUMMARY SECTION.
*****************************************************************
*PURPOSE: *
*****************************************************************
WRITE OUTPUT-RECORD FROM BLANK-LINE.
WRITE OUTPUT-RECORD FROM OR-SUMMARY.
4000-EXIT.
EXIT.
我在异常报告中的输出是:否。记录以上
3 0r4000700 03
**
6 074000Q00 06
***
* 7 075075000 07 750
*
* 8 06105 100 08 5 1
***
10 095000500 10
*
* 12 125999999 12 9999
***
19 08500050 19
*
21 125000899 21
***
23 A01001111 23
**
但应该是:错误报告
NO. CONTENTS ABOVE
2 032 200 02
****
3 0r4000700 03
**
5 073 73000 05
****
6 074000Q00 06
****
* 7 075075000 07 750
*
8 06105 100 08
****
9 011 52000 09
****
10 095000500 10
*
* 12 125999999 12 9999
***
19 08500050 19
*
* 20 091010000 20 100
21 125000899 21
***
23 A01001111 23
**
我的总结输出是:
不。地点 1 2 3 4 总计 01 XXXXXXX 00520 00000 00000 00000 00520 03 XXXXXXX 00000 00002 00000 00007 00009 04 XXXXXXX 00010 00010 00003 00000 00023 05 XXXXXXX 00000 00012 00000 00004 00016 06 XXXXXXX 00000 00000 00000 00004 00004 07 XXXXXXX 00000 00000 00730 00000 00730 08 XXXXXXX 00006 00000 00000 00004 00010 09 XXXXXXX 00100 00000 00000 00000 00100 总计 00636 00024 00733 00019 01412
应该是这样的:
总结报告 不。地点 1 2 3 4 总计 1 彼得斯,佛罗里达州 0 0 0 0 0 2 阿奇森,堪萨斯州 0 0 0 0 0 3 堪萨斯城,密苏里州 0 0 0 7 7 4丹佛,科罗拉多州 10 10 3 0 23 5 加利福尼亚州圣何塞 0 12 0 4 16 6 雷德蒙德, WA 0 0 0 4 4 7 休斯顿,德克萨斯州 0 0 0 0 0 8 托皮卡,堪萨斯州 6 0 0 4 10 9 堪萨斯州威奇托 100 0 0 0 100 10 杰斐逊城,密苏里州 0 0 0 0 0 11 街。路易·莫 0 0 0 0 0 总计 116 22 3 19 160