tags:

views:

60

answers:

2

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?

+2  A: 

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!

There's a relevant thread here.

ASalazar
A: 

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

matthewR
The real question was 'why is DHSEQN showing up as P, when the database shows it as S?'. (ASalazar provided the answer)
derek