我一直在阅读 LIKEDS
, TEMPLATE
, 和 BASED
试图确定是否有一种方法可以创建具有继承的数据结构模板(原型(prototype))。我有:
D costs DS QUALIFIED TEMPLATE
D material 6 0
D cutting 6 0
D ...etc...
D boxCosts DS LIKEDS(costs)
D folding 6 0
D ...etc...
D posterCosts DS LIKEDS(costs)
D laminating 6 0
D ...etc...
我希望 boxCosts 看起来像:
boxCosts:
material
cutting
folding
etc. (no laminating, this isn't a poster)
有没有办法实现这种类型的数据结构模板?我知道我可以这样做:
D boxCosts DS
D common LIKEDS(costs)
D folding 6 0
D ...etc...
但是当我想要一个平面结构时,这会创建一个层次结构。
我也许可以用抄写本来做到这一点,但我不知道是否只有我想要在自己的文件中的数据结构部分有一本抄写本,或者为整个应用程序有潜在复杂的条件抄写本会更糟复制这些信息的区域很小......?模板与我想要的非常接近,我怀疑我一定是遗漏了一些东西。
如果您想知道,我尝试创建像我展示的那样继承的数据结构时得到的编译错误是
RNF3703: The subfield or parameter definition is not specified within a group.
在 LIKEDS
下面的第一个 D 规范上关键词。谢谢阅读。
最佳答案
RPG 数据结构是内存映射。它们定义了一种在内存中以特定方式对变量进行分组和重叠的方法。这就是为什么如果你 LIKEDS() 你得到一个层次结构 - 编译器正在将层次结构从模板复制到你的目的地。
至少有一种方法可以使结构变平:
d costs ds template
d t_material 6s 0
d t_cutting 6s 0
d box e ds extname(boxcosts) prefix(t_) template
d boxCosts ds qualified
d material like(t_material)
d cutting like(t_cutting)
d folding like(t_folding)
boxCosts.cutting = 1;
boxCosts.folding = 2;
第一个结构在程序中定义;第二个是基于一个文件。我这样做只是为了展示两种不同的方式来定义子字段。
关于rpgle - 扩展模板化数据结构(继承),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21921623/