销售额高达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,所以如果你能尽可能地愚弄它,那就太棒了!
答案 0 :(得分: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个comp字段中说
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.