"RECORDING" 无效。 A "RECORDING MODE" OF "V" WAS ASSUDMED FOR 文件

"RECORDING" WAS INVALID. A "RECORDING MODE" OF "V" WAS ASSUMED FOR FILE

您好,我编写了一个 COBOL 程序,我正在使用一个文件,但是在定义文件定义时出现错误,请告诉我该怎么做。

       FILE-CONTROL.                
                                    
           SELECT CONTROL0-FILE     
                  ASSIGN TO CONTR.  
                                    
           SELECT APCO-FILE         
                  ASSIGN TO APCOOUT.
                                    
       FD  APCO-FILE.                                                  
I   A "RECORDING MODE" OF "V" WAS ASSUMED FOR FILE "APCO-FILE".   //ERR MSG        
           RECORDING MODE IS V                                         
S   "RECORDING" WAS INVALID.  SCANNING WAS RESUMED AT THE NEXT AREA "A" //ERR MSG
       ITEM, LEVEL-NUMBER, OR THE START OF THE                         //ERR MSG
           RECORD CONTAINS 30 TO 300                                   
           BLOCK CONTAINS 6152 CHARACTERS                              
           LABEL RECORDS STANDARD.                                     
                                                                       
       01  APCOIN-REC-1             PIC X(30).                         
       01  APCOIN-REC               PIC X(300).                        

问题是APCO-FILE之后的.,它结束了文件定义

       FD  APCO-FILE.                                                  
           RECORDING MODE IS V                                         
           RECORD CONTAINS 30 TO 300                                   
           BLOCK CONTAINS 6152 CHARACTERS                              
           LABEL RECORDS STANDARD.

改为

       FD  APCO-FILE                                                  
           RECORDING MODE IS V                                         
           RECORD CONTAINS 30 TO 300                                   
           BLOCK CONTAINS 6152 CHARACTERS                              
           LABEL RECORDS STANDARD.

我想您已经找到了解决方案。我想发表一些评论,以帮助您将来自己发现错误。

编译器读取它认为是语句的内容,然后验证语法,如果发现错误,则写入错误消息。然后继续下一条语句。

因此,首先,FD APCO-FILE. 之后出现错误消息这一事实表明编译器此时认为该语句已完成。其次,在 RECORDING MODE IS V 之后还有一条错误消息告诉你编译器认为这是另一条语句,它不理解它,因此 "RECORDING" was invalid ...

所以编译器认为以 RECORDING 开头的部分是一个新语句,而你的意思是它是 FD 语句的延续。想想什么会导致编译器和你不同意,你可能很快就会看到“。”在 APCO-FILE 之后不应该在那里。