我正在写一个COBOL代码,无法弄清楚为什么这个错误代码读取
“OPEN”不应该从区域“A”开始。处理好像在区域“B”中找到
具体而言,它指的是PROCEDURE DIVISION
的OPEN INPUT CUST-PROF
下的线
*-----------------------
IDENTIFICATION DIVISION.
*-----------------------
PROGRAM-ID. FSOC050
*--------------------
ENVIRONMENT DIVISION.
*--------------------
INPUT-OUTPUT SECTION.
*
FILE-CONTROL.
SELECT CUST-PROF ASSIGN TO CUSTPROF
ORGANIZATION IS SEQUENTIAL.
*-------------
DATA DIVISION.
*-------------
FILE SECTION.
FD CUST-PROF RECORDING MODE F.
01 CUST-PROF-01.
05 CUST-NO PIC X(6).
05 CUST-NAME PIC X(35).
05 CUST-STREET-ADDR PIC X(25).
05 CUST-CITY PIC X(11).
05 CUST-STATE PIC X(2).
05 CUST-CARD-TYPE PIC X(4).
05 CUST-CARD-EXP-MO PIC X(2).
05 CUST-CARD-EXP-YR PIC X(2).
05 CUST-CARD-NO PIC X(19).
05 FILLER PIC X(21).
*
WORKING-STORAGE SECTION.
01 CUST-NO-SRCH PIC X(6).
01 FLAGS.
05 LASTREC PIC X VALUE 'N'.
88 LAST-REC VALUE 'Y'.
*------------------
PROCEDURE DIVISION.
*------------------
OPEN-FILES.
ACCEPT CUST-NO-SRCH.
*
DISPLAY "SEARCH RECORDS FOR " CUST-NO-SRCH.
*
OPEN INPUT CUST-PROF.
*
PERFORM UNTIL LAST-REC
READ CUST-PROF
AT END SET LAST-REC TO TRUE
NOT AT END
IF CUST-NO-SRCH = CUST-NO
DISPLAY "CUSTOMER NAME = "
CUST-NAME
END-IF
END-READ
END-PERFORM.
*
CLOSE CUST-PROF.
STOP RUN.
*
我已经编辑了你的问题,要求代码缩进,以显示有问题的行(你已经看过):
OPEN INPUT CUST-PROF.
如果缩进对您来说看起来不一样,则代码可能包含选项卡。
回到问题:
为什么这个错误代码读取
“OPEN”不应该从区域“A”开始。处理好像在区域“B”中找到
编译器检查ANSI COBOL 85规则:语句应该从区域B开始:
Columns Field Description
1-6 Sequence Area Often empty or line numbers, look out for shop specific rules
7 Indicator Asterisk (*) = comment line, Hyphen (-) = continuation line,
Slash ( / ) = form feed, D = debugging line
8-11 Area A COBOL definitions: divisions, sections, paragraphs, records and
some other entries must *begin* in Area A
12-72 Area B everything else, including COBOL statements, must begin in area B
73-nn Identification Area may contain notes, look out for shop specific rules
编译器说:我很好地猜测这一行是从OPEN
语句开始的有效行。