ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to code table in D Spec

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to code table in D Spec

    I want to use operation 'lookup' for lookup table 1 and 2. I will code the table at the bottom of RGPLE source as sample below:

    **
    A1 Import
    B1 Local
    C1 Production
    D1 Return

    How do I code the Table1 and Table2 in D Spec?

  • #2
    Welcome - Here you go

    This is an example using compile time array(s)

    Code:
          *====================================                               
          *
          *====================================                               
         d CODE            s              2    DIM(8) CTDATA PERRCD(4)
         d DESC            s             10    DIM(4) CTDATA PERRCD(1)
         d x               s              3  0
         d INCODE          s              2
         d OUTDSC          s             10
          *
         c                   eval      x = 1
         c     INCODE        LOOKUP    CODE(x)                                99
         c                   if        %Found
         c                   eval      OUTDSC = %trim(DESC(X))
         c                   endif
          *
         c     *entry        plist
         c                   parm                    INCODE
         c                   parm                    OUTDSC
          *
         C                   eval      *INLR = *on
          *====================================                               
    **
    A1A2A3A4
    **
    Import
    Local
    Production
    Return

    hope that helps

    Jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      You need to define an alternating table (or array)

      D Table1 S 2A DIM(10) PERRCD(1) CTDATA
      D Table2 S 10A DIM(10) ALT(Table1)

      The table elements should be next to each other, i.e.

      A1Import
      B1Local

      without the space between them, unless the first element is a 3 pos field, or you want the 2nd element to start with a space.

      Comment

      Working...
      X