2

销售额不超过10,000的员工人数:ZZ9

销售额从 10,001 到 20,000 的员工人数:ZZ9

这就是我想要完成的事情 ZZ9 是变量。我不太确定该怎么做,我的书被偷了,所以希望能得到一些帮助。在我的工作存储部分,我有

 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: "
 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: " 

在我的程序部门中,我有

 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.

但无法弄清楚如何在这些语句的末尾添加变量。非常感谢任何和所有帮助。我像三天前一样开始使用cobol,所以如果你能尽可能地把所有东西都弄糊涂,那就太好了!

4

1 回答 1

2

只需在数据声明的末尾添加您的数字字段:

    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 Number-employee-to-10000  pic zzz,zz9
    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 Number-employee-above-10000  pic zzz,zz9.

你在 2 个比较字段中的记录数说

   01  ws-accumulators
       03 employee-accum-1      pic s9(9) comp. 
       03 employee-accum-2      pic s9(9) comp. 

您应该累积这些,因为数字编辑字段(pic zz9)实际上是文本字段而不是数字(并且许多编译器无论如何都不会让您这样做)。比较字段应该更快。

然后在程序部门将总计移动到上面的新字段

   4000-PROCESS.
          Move  employee-accum-1        to Number-employee-to-10000 
          Move  employee-accum-2        to Number-employee-above-10000

          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.
于 2014-12-04T02:29:28.717 回答