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?
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.