-2

我正在使用 IBM 大型机制作一个工资单项目,并要求我每个月为一名员工创建一份工资单报告。该工资单应该以如下格式存储到 VSAM 文件中:

样本报告格式 As 要存储到 VSAM

可以通过 COBOL 程序从 DB2 获取数据,但问题是我不知道以这种用户格式化样式将内容写入文件的方法。

所以任何人都可以给我发一个 COBOL 代码来帮助我,因为当我在互联网上搜索时,我所能找到的只是如何以键序列记录格式存储数据。

另外请告诉我应该使用哪种类型的 VSAM。

4

1 回答 1

0
   Id division.
   Program-id. VSAMSEQW.
   Environment division.
   Input-output section.
   File-control.
       Select F1
          Assign to AS-DD1
          Organization is sequential
          File status is FS FS2.
   Data division.
   File section.
   FD  F1.
   1   R1 pic X(133).
   Working-storage section.
   1 fs pic 99.
   1 fs2.
     2 rc pic s9(4) binary.
     2 fc pic s9(4) binary.
     2 fb pic s9(4) binary.
   1 X pic X(10).
   Procedure division.
   Declaratives.
   F1-error section.
       Use after standard error procedure on F1.
   1.  Display "Error declarative entered"
       Display "  File status: " fs
       Display "  VSAM return code:   " rc
       Display "  VSAM function code: " fc
       Display "  VSAM feedback code: " fb
       Display "Testcase VSAMSEQW failed!"
       Move 16 to return-code
       Stop run
       .
   End declaratives.
   MainPgm section.
       Display "Entering VSAMSEQW"

       Open output F1

  * Do whatever you need to get data and update R1
       Move "Line 1" to R1
       Write R1
  * 2nd output line
       Move "Line 2" to R1
       Write R1

       Close F1

       Display "Exiting VSAMSEQW"
       Goback.
于 2018-08-13T18:20:40.260 回答