一个简单的例子而已。
IDENTIFICATION DIVISION.
PROGRAM-ID. AMBCDBTD .
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-9000.
OBJECT-COMPUTER. IBM-9000.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.
….
WORKING-STORAGE SECTION.
01 NAME-TABLE.
03 WK-NAME OCCURS 3 TIMES.
05 FNAME PIC X(12).
05 LNAME PIC X(12).
01 WK-INDEX PIC 9(1).
…..
/*很明显索引越界
PERFORM VARYING WK-INDEX FROM 1 BY 1 UNTIL WK-INDEX > 4
MOVE 'LEYOND' TO FNAME(WK-INDEX)(1:6)
MOVE WK-INDEX TO FNAME(WK-INDEX)(7:1)
MOVE 'LIN' TO LNAME(WK-INDEX)(1:3)
MOVE WK-INDEX TO LNAME(WK-INDEX)(4:1)
END-PERFORM.
程序编译自然没有问题,这是逻辑问题,编译器无法检查。所以顺利通过。接下来写一个简单的JOB:
//AMBCDBTD EXEC PGM= AMBCDBTD
//SYSOUTPT INCLUDE MEMBER=SYSOUTPT
你把这个job丢出去,报错3000。错误信息如下:The reference to table WK-NAME by verb number 01 on line 000140 address an area outside the region of the table, From compile unit AMBCDBTD at entry point AMBCDBTD at compile unit offset +0000073C at entry offset +0000073C at address 16F01054. 这里我们看到信息中的offset,它告诉错位位置在程序AMBCDBTD中的偏移量,那么我们找到刚才编译AMBCDBTD的信息,搜索073c,找到结果如下: 000140 MOVE 000704 F270 D108 8058 PACK 264(8,13),88(1,8) 000738 4110 A2B2 LA 1,690(0,10) 00073C 0DEF BASR 14,15 说明MOVE语句出现了问题,我们继续查找看看是哪行出问题了,找到MOVE左边的000140,搜索得到: 000140 1 MOVE ‘LEYOND’ TO FNAME(WK-INDEX)(1:6) 这样的话比较清楚了,很容易能察觉到wk-index超出了FNAME表的界限。
|