RPG编译器将类型S转换为类型P?
这是我的情况: 我的程序 A 如下所示:
Fmfile IF E K DISK USROPN d grue s like(dhseqn) d C *ENTRY PLIST C PARM grue c open mfile c*** do something with grue c close mfile c eval *inlr = *on
dhseqn 是一个 2,0 S 字段。
编译清单向我展示了这一点:
*RNF7031 DHSEQN P(2,0) 000200 1000002D GRUE P(2,0) 000200D 000500M 000700 000800M BASED(_QRNL_PRM+)
当我使用已声明为 2,0 S 的参数调用程序 A 时,我收到十进制数据错误。
这是预期的结果,还是编译器错误?
Here is my situation:
I have program A which looks like this:
Fmfile IF E K DISK USROPN d grue s like(dhseqn) d C *ENTRY PLIST C PARM grue c open mfile c*** do something with grue c close mfile c eval *inlr = *on
dhseqn is a 2,0 S field.
The compile listing shows me this:
*RNF7031 DHSEQN P(2,0) 000200 1000002D GRUE P(2,0) 000200D 000500M 000700 000800M BASED(_QRNL_PRM+)
And when I call program A with a parameter that has been declared as 2,0 S, I get a decimal data error.
Is this expected, or is this a compiler bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
RPG 编译器(甚至在 ILE 之前)将数据库字段转换为压缩格式。有时您会发现事实并非如此,例如,如果您在数据结构中使用分区文件字段,则该字段将保持分区状态,但您不使用的同一文件的每个分区字段都会被打包。
如果您确实需要从文件字段中点赞,请定义一个虚拟数据结构以保持其分区。
更好的是,如果你的入口参数没有被修改,在程序的原型中用 Const 关键字定义它,类型就会自动转换,甚至接受表达式和常量!
这是一篇非常好的文章在过程原型和自动转换上使用 Const。
The RPG compiler (even before ILE) converts database fields to packed. Sometimes you'll find it doesn't, for example, a zoned file field will stay zoned if you use it in a data structure, but every zoned field of the same file you don't will become packed.
If you really need to Like from a file field, define a dummy data structure to keep it zoned.
Even better, if your entry parameter is not modified, define it in the program's prototype with the Const keyword and the type will be converted automagically, even accepting expressions and constants!
Here's a really good article about using Const on procedure prototypes and automatic conversion.
grue 定义中的“s”并不是指数据类型,而是将其定义为“独立”字段。 grue 的数据类型被指定为 LIKE(dhseqn),您的编译列表显示为 P(2,0)。
The 's' in the definition of grue does not refer to the data type, but rather defines it as a 'standalone' field. The data type for grue is specified as LIKE(dhseqn) which your compile listing shows as P(2,0).