不是唯一定义的名称?

时间:2014-12-11 22:15:26

标签: cobol mainframe

我一直收到错误

“LOWMID-COMMISSION-CTR”不是唯一定义的名称。定义                         无法根据具体情况确定使​​用情况。

在我所有的柜台上都是类似的。我不知道我在哪里出错了,当它显然在工作存储部分时,它怎么不是一个唯一定义的名字?我把它放在其他地方,以便它是一个唯一定义的名称?下面我展示了我定义计数器的位置,以及计数器的使用位置。

   IDENTIFICATION DIVISION.
   PROGRAM-ID. LAB3.
   AUTHOR.  

  ******************************************************************
   ENVIRONMENT DIVISION.
  *  defines the external files - an input file and output file
   INPUT-OUTPUT SECTION.
   FILE-CONTROL.


       SELECT SALES-FILE ASSIGN TO DATAIN
          FILE STATUS IS EF-STATUS.

       SELECT REPORT-FILE ASSIGN TO DATAOUT
          FILE STATUS IS PF-STATUS.
   DATA DIVISION.
  * has two sections - the file section that describes the files
  * and the working storage section - where output lines and
  * processing variables are defined

   FILE SECTION.

   FD SALES-FILE.
   01 SALES-RECORD.
       05 EMPLOYEE-NAME-IN PIC X(24).
       05 SALES-IN           PIC 99999.
       05 FILLER             PIC X(51).
   FD REPORT-FILE.
   01 REPORT-RECORD                PIC X(80).

   WORKING-STORAGE SECTION.

   01 FLAGS-AND-ACCUMLATORS.
       05 LOW-COMMISSION-CTR   PIC 99999 VALUE ZERO.
       05 LOWMID-COMMISSION-CTR PIC 99999 VALUE ZERO.
       05 HIGHMID-COMMISSION-CTR PIC 99999 VALUE ZERO.
       05 HIGH-COMMISSION-CTR   PIC 99999 VALUE ZERO.
       05 TOTAL-SALES PIC $$$,$$9.99 VALUE ZERO.
       05 TOTAL-COMMISSION PIC $$$,$$9.99 VALUE ZERO.
       05   END-OF-FILE            PIC XXX VALUE "NO".
       05   EF-STATUS              PIC 99  VALUE 0.
       05   PF-STATUS              PIC 99  VALUE 0.
       05   COMMISSION             PIC 99999V99.

   01 REPORT-BLANK-LINE.
       05                          PIC X(80).

   01  HEADING-LINE-1.
       05                          PIC X(30) VALUE SPACES.
       05                          PIC X(19) VALUE
            "COMPANY OF AARON".



   01  HEADING-LINE-2.
        05                          PIC X(30) VALUE SPACES.
        05                          PIC X(19) VALUE
              "KEARNEY, MISSOURI".
   01  HEADING-LINE-3.
        05                      PIC X(03) VALUE SPACES.
        05                      PIC X(48) VALUE
              "Number of employees with up to 10,000 in sales: ".
        05 LOW-COMMISSION-CTR PIC 99999.
   01  HEADING-LINE-4.
        05                      PIC X(03) VALUE SPACES.
        05                      PIC X(52) VALUE
              "Number of employees from 10,001 to 20,000 in sales: ".
        05 LOWMID-COMMISSION-CTR PIC 99999.
   01 HEADING-LINE-5.
        05                      PIC X(03) VALUE SPACES.
        05                      PIC X(52) VALUE
           "Number of employees from 20,001 to 30,000 in sales: ".
        05 HIGHMID-COMMISSION-CTR PIC 99999.
   01 HEADING-LINE-6.
        05                      PIC X(03) VALUE SPACES.
        05                      PIC X(42) VALUE
           "Number of employees over 30,000 in sales: ".
        05 HIGH-COMMISSION-CTR PIC 99999.
   01 HEADING-LINE-7.
        05                      PIC X(03) VALUE SPACES.
        05                      PIC X(13) VALUE
            "Total Sales: ".
        05 TOTAL-SALES PIC $$$,$$9.99.
   01 HEADING-LINE-8.
        05                      PIC X(03) VALUE SPACES.
        05                      PIC X(18) VALUE
             "TOTAL COMMISSION: ".
        05 TOTAL-COMMISSION PIC $$$,$$9.99.

   01  COLUMN-HEADING-1.
        05                      PIC X(03) VALUE SPACES.
        05                      PIC X(24) VALUE "SALESPERSON".
        05                      PIC X(15) VALUE "SALES".
        05                      PIC X(10) VALUE "COMMISSION".
   01  COLUMN-HEADING-2.
        05                      PIC X(14) VALUE "SUMMARY REPORT".


   01  DETAIL-LINE.
        05                      PIC X(03) VALUE SPACES.
        05 EMPLOYEE-NAME-OUT    PIC X(24).
        05 SALES-OUT            PIC $$$,$$9.
        05                      PIC X(05) VALUE SPACES.
        05 COMMISSION-OUT       PIC $$$,$$9.99.


   PROCEDURE DIVISION.

   1000-MAIN-CONTROL.
       PERFORM 2000-INITIALIZE.
       PERFORM UNTIL END-OF-FILE = "YES"
         READ SALES-FILE
           AT END
             MOVE "YES" TO END-OF-FILE
           NOT AT END
             PERFORM 3000-PROCESS
       END-PERFORM
       PERFORM 4000-PROCESS.
       STOP RUN.

   2000-INITIALIZE.
          OPEN INPUT SALES-FILE
               OUTPUT REPORT-FILE.

       WRITE REPORT-RECORD         FROM HEADING-LINE-1.
       WRITE REPORT-RECORD         FROM HEADING-LINE-2.
       WRITE REPORT-RECORD         FROM REPORT-BLANK-LINE.
       WRITE REPORT-RECORD         FROM COLUMN-HEADING-1.
       WRITE REPORT-RECORD         FROM REPORT-BLANK-LINE.

    3000-PROCESS.

       IF SALES-IN < 10001
         MULTIPLY SALES-IN BY .04 GIVING COMMISSION
          ADD 1 TO LOW-COMMISSION-CTR
          ADD COMMISSION TO TOTAL-COMMISSION
       END-IF.


       IF SALES-IN > 10000 AND < 20001
         MULTIPLY SALES-IN BY .055 GIVING COMMISSION
          ADD 1 TO LOWMID-COMMISSION-CTR
          ADD COMMISSION TO TOTAL-COMMISSION
       END-IF.

       IF SALES-IN > 20000 AND < 30000
         MULTIPLY SALES-IN BY .065 GIVING COMMISSION
          ADD 1 TO HIGHMID-COMMISSION-CTR
          ADD COMMISSION TO TOTAL-COMMISSION
          END-IF.

       IF SALES-IN > 30000
         MULTIPLY SALES-IN BY .075 GIVING COMMISSION
          ADD 1 TO HIGH-COMMISSION-CTR
          ADD COMMISSION TO TOTAL-COMMISSION
          END-IF.

       MOVE EMPLOYEE-NAME-IN       TO EMPLOYEE-NAME-OUT.
       MOVE SALES-IN               TO SALES-OUT.
       MOVE COMMISSION             TO COMMISSION-OUT.

       WRITE REPORT-RECORD         FROM DETAIL-LINE.

   4000-PROCESS.
       WRITE REPORT-RECORD         FROM REPORT-BLANK-LINE.
       WRITE REPORT-RECORD         FROM COLUMN-HEADING-2.
       WRITE REPORT-RECORD         FROM HEADING-LINE-3.
       WRITE REPORT-RECORD         FROM HEADING-LINE-4.
       WRITE REPORT-RECORD         FROM HEADING-LINE-5.
       WRITE REPORT-RECORD         FROM HEADING-LINE-6.
       WRITE REPORT-RECORD         FROM HEADING-LINE-7.
       WRITE REPORT-RECORD         FROM HEADING-LINE-8.
   4000-TERMINATE.
       CLOSE SALES-FILE, REPORT-FILE.

1 个答案:

答案 0 :(得分:2)

变量LOWMID-COMMISSION-CTR定义了两次。

  • 一次在FLAGS-AND-ACCUMLATORS
     01 FLAGS-AND-ACCUMLATORS.
        05 LOW-COMMISSION-CTR   PIC 99999 VALUE ZERO.
        05 LOWMID-COMMISSION-CTR PIC 99999 VALUE ZERO.
  • 一次在HEADING-LINE-4
     01  HEADING-LINE-4.
         05                      PIC X(03) VALUE SPACES.
         05                      PIC X(52) VALUE
               "Number of employees from 10,001 to 20,000 in sales: ".
         05 LOWMID-COMMISSION-CTR PIC 99999.

所以要么

  • 将其中一个LOWMID-COMMISSION-CTR重命名为
     01  HEADING-LINE-4.
         05                      PIC X(03) VALUE SPACES.
         05                      PIC X(52) VALUE
               "Number of employees from 10,001 to 20,000 in sales: ".
         05 HEADER-LOWMID-COMMISSION-CTR PIC 99999.
  • 完全符合该领域的资格。
     Add 1 
      to    LOWMID-COMMISSION-CTR 
         of FLAGS-AND-ACCUMLATORS

同样适用于其他FLAGS-AND-ACCUMLATORS字段