如何让这个棒球节目达到 运行?

How do I get this baseball program to run?

我有这个 Cobol 程序,我正在尝试编写,但我不能 运行 因为有很多错误(red/blue 行)我相信它与阅读有关进出文件。我在想错误可能是因为我没有放入 FD 但当我这样做时,它仍然出错。我的 seq 文件名为 BASEBALL-2.seq.

   WORKING-STORAGE SECTION.
   01  ARE-THERE-MORE-RECORDS      PIC X(3)  VALUE 'YES'.

   01 LINE-COUNT                   PIC 99    VALUE ZEROS.

   01  WS-DATE.
       05  RUN-YEAR                PIC XX.
       05  RUN-MONTH               PIC XX.
       05  RUN-DAY                 PIC XX.
   01  HEADING-LINE-1.
       05                          PIC X(24) VALUE SPACES.
       05                          PIC X(26)
           VALUE 'BASEBALL PLAYER STATISTICS'.
       05                          PIC X(12) VALUE SPACES.
       05  HL-1-DATE.
           10  MONTH-2             PIC XX.
           10                      PIC X      VALUE '/'.
           10  DAY-2               PIC XX.
           10                      PIC X      VALUE '/'.
           10  YEAR-2              PIC XX.
       05                          PIC X(6)   VALUE SPACES.
       05  PAGE-1                  PIC X(4)   VALUE 'PAGE'.

   01  HEADING-LINE-2.
       05                          PIC X(6)   VALUE 'LEAGUE'.
       05                          PIC X(3)   VALUE SPACES.
       05                          PIC X(4)   VALUE 'TEAM'.
       05                          PIC X(5)   VALUE SPACES.
       05                          PIC X(4)   VALUE 'NAME'.
       05                          PIC X(10)  VALUE SPACES.
       05                          PIC X(4)   VALUE 'HITS'.
       05                          PIC X(6)   VALUE SPACES.
       05                          PIC X(7)   VALUE 'AT BATS'.
   01  DETAIL-LINE.
       05 BLANK-A-OUT              PIC X      VALUE SPACES.
       05 DL-LEAGUE                PIC XX.
       05 BLANK-B-OUT              PIC X(3)   VALUE SPACES.
       05 DL-TEAM                  PIC X(3).
       05 BLANK-C-OUT              PIC X(3)   VALUE SPACES.
       05 DL-NAME                  PIC X(10).
       05 BLANK-D-OUT              PIC X(3)   VALUE SPACES.
       05 DL-HITS                  PIC ZZ9.
       05 BLANK-E-OUT              PIC X(3)   VALUE SPACES.
       05 DL-AT-BATS               PIC ZZ9.

   PROCEDURE DIVISION.
   100-MAIN.
       OPEN INPUT BASEBALL-FILE-IN
       OPEN OUTPUT BASEBALL-FILE-OUT

       ACCEPT WS-DATE FROM DATE
       MOVE RUN-MONTH TO MONTH-2
       MOVE RUN-DAY TO DAY-2
       MOVE RUN-YEAR TO YEAR-2
       WRITE BASEBALL-RECORD-OUT

       PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO '
           READ BASEBALL-FILE-IN
               AT END
                   MOVE 'NO ' TO ARE-THERE-MORE-RECORDS
               NOT AT END
                   PERFORM 200-PROCESS-ONE-RECORD
           END-READ
       END-PERFORM

       CLOSE BASEBALL-FILE-IN
       CLOSE BASEBALL-FILE-OUT
       STOP RUN.


   200-PROCESS-ONE-RECORD.
       MOVE LEAGUE-IN TO DL-LEAGUE
       MOVE SPACES TO BLANK-A-OUT
       MOVE TEAM-IN TO DL-TEAM
       MOVE SPACES TO BLANK-B-OUT
       MOVE NAME-IN TO DL-NAME
       MOVE SPACES TO BLANK-C-OUT
       MOVE HITS-IN TO DL-HITS
       MOVE SPACES TO BLANK-D-OUT
       MOVE AT-BATS-IN TO DL-AT-BATS
       MOVE SPACES TO BLANK-E-OUT
       WRITE BASEBALL-RECORD-OUT
           AFTER ADVANCING 2 LINES.

   300-LINE.
       IF  LINE-COUNT >= 50
           PERFORM 400-NEXT-PAGE
       END-IF
       WRITE BASEBALL-RECORD-OUT
           AFTER ADVANCING 1 LINE
       ADD 1 TO LINE-COUNT.

   400-NEXT-PAGE.
       WRITE BASEBALL-RECORD-OUT
           AFTER ADVANCING PAGE
       MOVE ZEROS TO LINE-COUNT.

您 post 从 WORKING STORAGE 开始。你能告诉我们 FILE SECTION 是怎么写的吗?另外,您收到的错误。

考虑:

  • 使用 FILLER 而不是字段和变量名称的空格。
  • 注意流程,您不是在调用 300-LINE 段落。 PERFORM 在另一个段落开始时中断。
  • 200-PROCESS-ONE-RECORD 中,您没有将 2 行添加到 LINE-COUNT

其余的,我觉得很完美。