【问题标题】:Printing report on a VSAM file在 VSAM 文件上打印报告
【发布时间】:2018-07-18 18:08:12
【问题描述】:

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

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

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

另外请说明我应该使用哪种类型的 VSAM。

【问题讨论】:

  • 您实际上并不需要 VSAM 来输出报告。但如果 VSAM 是强制性的,您可以选择按顺序访问 ESDS。要输出不同的行,您可以使用所需的不同字段重新定义一个 133 长度的填充符,或者将每一行写入文件。

标签: db2 cobol mainframe jcl vsam


【解决方案1】:
   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.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-15
    • 1970-01-01
    • 2011-12-03
    • 2014-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多