COBOL中的IGZ0201W和IGZ0035S错误

问题描述

      *-----------------------
       IDENTIFICATION DIVISION.
      *-----------------------
       PROGRAM-ID.    TOPACCTS
       AUTHOR.        Sohan Kundu.
      *--------------------
       ENVIRONMENT DIVISION.
      *--------------------
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT PRINT-LINE ASSIGN TO PRTLINE.
           SELECT ACCT-REC   ASSIGN TO ACCTREC.
      *-------------
       DATA DIVISION.
      *-------------
       FILE SECTION.
       FD  PRINT-LINE RECORD CONTAINS 80 CHaraCTERS RECORDING MODE F.
       01  PRINT-REC.
           05  FILLER         PIC X(01) VALUE SPACES.
           05  FirsT-NAME-O   PIC X(11).
           05  FILLER         PIC X(02) VALUE SPACES.
           05  LAST-NAME-O    PIC X(22).
           05  FILLER         PIC X(02) VALUE SPACES.
           05  ACCT-BALANCE-O PIC X(12).
           05  FILLER         PIC X(30) VALUE SPACES.
      *
       FD  ACCT-REC RECORD CONTAINS 80 CHaraCTERS RECORDING MODE F.
       01  ACCT-FIELDS.
           05  FirsT-NAME         PIC X(11).
           05  LAST-NAME          PIC X(22).
           05  FILLER             PIC X(28).
           05  ACCT-BALANCE       PIC X(12).
           05  FILLER             PIC X(7).
      *
       WORKING-STORAGE SECTION.
       01  FLAGS.
           05 LASTREC          PIC X VALUE SPACE.
      *
       01  TOTAL-CLIENTS.
           05 FILLER              PIC X(14) VALUE
              '# OF RECORDS: '.
           05 CLIENTS             PIC 9(3) VALUE ZERO.
           05 FILLER              PIC X(63) VALUE SPACES.
      *
       01  HEADER-1.
           05  FILLER PIC X(30) VALUE 'REPORT FOR TOP ACCOUNT HOLDERS'.
           05  FILLER PIC X(50) VALUE SPACES.
      *
       01  HEADER-2.
           05  FILLER         PIC X(05) VALUE 'Year '.
           05  HDR-YR         PIC 9(04).
           05  FILLER         PIC X(02) VALUE SPACES.
           05  FILLER         PIC X(06) VALUE 'Month '.
           05  HDR-MO         PIC X(02).
           05  FILLER         PIC X(02) VALUE SPACES.
           05  FILLER         PIC X(04) VALUE 'Day '.
           05  HDR-DAY        PIC X(02).
           05  FILLER         PIC X(53) VALUE SPACES.
      *
       01  HEADER-3.
           05  FILLER         PIC X(11) VALUE 'First Name '.
           05  FILLER         PIC X(02) VALUE SPACES.
           05  FILLER         PIC X(10) VALUE 'Last Name '.
           05  FILLER         PIC X(14) VALUE SPACES.
           05  FILLER         PIC X(08) VALUE 'Balance '.
           05  FILLER         PIC X(35) VALUE SPACES.
      *
       01  HEADER-4.
           05  FILLER         PIC X(11) VALUE '-----------'.
           05  FILLER         PIC X(02) VALUE SPACES.
           05  FILLER         PIC X(10) VALUE '----------'.
           05  FILLER         PIC X(14) VALUE SPACES.
           05  FILLER         PIC X(08) VALUE '--------'.
           05  FILLER         PIC X(35) VALUE SPACES.
      *
       01 WS-CURRENT-DATE-DATA.
           05  WS-CURRENT-DATE.
               10  WS-CURRENT-YEAR         PIC 9(04).
               10  WS-CURRENT-MONTH        PIC 9(02).
               10  WS-CURRENT-DAY          PIC 9(02).
           05  WS-CURRENT-TIME.
               10  WS-CURRENT-HOURS        PIC 9(02).
               10  WS-CURRENT-MINUTE       PIC 9(02).
               10  WS-CURRENT-SECOND       PIC 9(02).
               10  WS-CURRENT-MILLISECONDS PIC 9(02).
      *
      *------------------
       PROCEDURE DIVISION.
      *------------------
       OPEN-FILES.
           OPEN INPUT  ACCT-REC.
           OPEN OUTPUT PRINT-LINE.
      *
       WRITE-HEADERS.
           MOVE FUNCTION CURRENT-DATE TO WS-CURRENT-DATE-DATA.
           MOVE WS-CURRENT-YEAR  TO HDR-YR.
           MOVE WS-CURRENT-MONTH TO HDR-MO.
           MOVE WS-CURRENT-DAY   TO HDR-DAY.
           WRITE PRINT-REC FROM HEADER-1.
           WRITE PRINT-REC FROM HEADER-2.
           MOVE SPACES TO PRINT-REC.
           WRITE PRINT-REC AFTER ADVANCING 1 LInes.
           WRITE PRINT-REC FROM HEADER-3.
           WRITE PRINT-REC FROM HEADER-4.
           MOVE SPACES TO PRINT-REC.
      *
       READ-NEXT-RECORD.
           PERFORM READ-RECORD
            PERFORM UNTIL LASTREC = 'Y'
            PERFORM IS-BALANCE-HIGH
            PERFORM READ-RECORD
            END-PERFORM
           .
      *
       CLOSE-STOP.
           WRITE PRINT-REC FROM TOTAL-CLIENTS.
           CLOSE ACCT-REC.
           CLOSE PRINT-LINE.
           STOP RUN.
      *
       READ-RECORD.
           READ ACCT-REC
           AT END MOVE 'Y' TO LASTREC
           END-READ.
      *
       IS-BALANCE-HIGH.
           IF FUNCTION NUMVAL-C(ACCT-BALANCE) > 8500000 THEN
              ADD 1 TO CLIENTS
              PERFORM WRITE-RECORD
           END-IF.
      *
       WRITE-RECORD.
           MOVE FirsT-NAME   TO  FirsT-NAME-O.
           MOVE LAST-NAME    TO  LAST-NAME-O.
           MOVE ACCT-BALANCE TO  ACCT-BALANCE-O.
           WRITE PRINT-REC.
      *

我想从输入文件中读取帐户详细信息,并在余额超过8500000时打印。

代码显示以下错误

 IGZ0201W A file attribute mismatch was detected. File PRINT-LINE in program TOPACCTS had a record length of 81 and
          the file specified in the ASSIGN clause had a record length of 80.
 IGZ0035S There was an unsuccessful OPEN or CLOSE of file PRTLINE in program TOPACCTS at relative location X'1E8'.
          Neither FILE STATUS nor an ERROR declarative were specified. The status code was 39.
          From compile unit TOPACCTS at entry point TOPACCTS at compile unit offset +000001E8 at entry offset +000001E8
          at address 1B8001E8.

解决方法

在用于执行此程序(作为批处理作业)的JCL中,在带有EXEC PGM=TOPACCTS的步骤中,确保为输出文件PRTLINE使用DD卡,该文件看起来像与此类似:

//PRTLINE  DD DISP=(NEW,CATLG),DSN=YOUR.DSN.GOES.HERE,//             UNIT=SYSDA,SPACE=(CYL,(5,5)),//             RECFM=FB,LRECL=80

这样,您将避免使用状态码“ 39”,该状态码表示记录长度80(如程序中带有CONTAINS 80 CHARACTERS的记录长度)与您在JCL中指定的记录长度之间不匹配DD卡。