JRecord - 处理 Cobol Copybook 中的重复列

JRecord - Handling duplicate columns in cobol copybook

我在 git https://github.com/tmalaska/CopybookInputFormat/ 上使用 CopybookInputFormat 从 COBOL copybook 生成配置单元 table 定义。我的字帖有很多填充物(重复的列) 但看起来 JRecord 没有正确处理重复的列名。 对于下面的字帖,当我迭代列时,JRecord 只打印第二个 Filler 而忽略第一个 filler。

  05 Birth-day              PIC X(002)
  05 Filler                 PIC X(008)
  05 Birth-Month            PIC X(002)
  05 Filler                 PIC X(008)
  05 Birth-year             PIC X(004)

有人对此有任何解决方案吗?我知道 JRecord 0.80.6 以后正在处理重复的列,但是方法 getUniqueField("FIRST-NAME", "PRESIDENT") 需要一个组名..但是如果组有重复的列怎么办?

您应该不需要导入 Filler。在Cobol中,无法直接访问一个Filler。在 Cobol 中,Filler 表示 Ignore this Field(或通过其他方法访问它)。

Cobol-Copybook 就像一块内存上的掩码;填充符用于跳过一些内存。

  Data         !##........##........##   (# - accessible bytes; . - inaccessible bytes)
                ^         ^         ^                               
                !         !         !
Birth-day    ---+         !         ! 
Filler                    !         ! 
Birth-Month  -------------+         !  
Filler                              !
Birth-year   -----------------------+   

填料可用于:

  • 屏蔽不再使用的字段。
  • 在重新定义中使用了掩码数据
  • 当您不需要所有字段时创建一个简化版本的字帖
  • 正在初始化输出字段,即
     05 report-Birth-date
        10 dd          pic 99.
        10 filler      pic '/'.
        10 mm          pic 99.  
        10 filler      pic '/'.
        10 yyyy        pic 9999.
  • 设置Table数据
     05 codes.
        10 code occurs 5  pic 99.
     05 filler redefines codes pic x(10)
        value '0204050612'.

我会问 Cobol 专家 你在哪里工作 发生了什么事 ?? ?。可能的答案可能是:

  • 可能不需要填充数据。
  • 您应该使用不同的更复杂的 Copybook。
  • 应使用实名填空者更新字帖。