Results 1 to 3 of 3

Thread: How to code table in D Spec

  1. #1
    Code400 Newbie colourwolf82's Avatar
    Join Date
    Oct 2004
    Location
    Malaysia
    Age
    32
    Posts
    16
    Rep Power
    0

    Question 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. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Age
    21
    Posts
    1,000,000
     

  3. #2
    Driver of cars, eater of food jamief's Avatar
    Join Date
    Jan 2004
    Location
    Belvidere, IL - United States of America
    Age
    49
    Posts
    9,416
    Rep Power
    12606

    Post 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

  4. #3
    Experienced Forum Member arrow483's Avatar
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    1,741
    Rep Power
    4219
    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.

  5. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

Facebook Comments


Similar Threads

  1. FINAL code API
    By casporov in forum RPG/RPGLE
    Replies: 2
    Last Post: January 13th, 2007, 12:16 PM
  2. Create Table w/Identity Column
    By Pete in forum SQL
    Replies: 1
    Last Post: October 23rd, 2006, 01:34 PM
  3. create table with D spec
    By colourwolf82 in forum RPG/RPGLE
    Replies: 9
    Last Post: March 21st, 2006, 11:03 AM
  4. Jobd
    By ris_skma in forum RPG/RPGLE
    Replies: 1
    Last Post: July 27th, 2005, 06:34 AM
  5. Replies: 8
    Last Post: June 17th, 2005, 02:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •