ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How Numeric & char fields are defined in RPG400

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

  • How Numeric & char fields are defined in RPG400

    As i am converting some codes from RPGLE to RPG400 i need to get following information

    1. How does Numeric field gets defined ??

    I guess by Z-ADD, but then what about numeric data type(Packed,Zoned, etc), where are they defined.

    2. How does Char field gets defined ??

    I guess they can be defined in any opcode - like move, but again where do we define their length etc.

    Does thes declaration (numeric & char) are global??

    If we define numeric/char inside a subroutine, then it will be global or local for that subroutine??

    Thanks in advance
    SAM

  • #2
    Hello SAM

    You must define them in the D spec. I mean you dont have to but you should......Your next conversion(down the road) will be free format. Then you wont be able to define fields in the C specs.


    Okay......

    In CLLE programs just defining something as Dec without length will default to a length of 15 5....

    All decimal fields are defaulted to PACKED you must change it to "S" for signed ......etc

    default length of char is 256 if no length entered.

    Code:
         D @Scrn1          S              1    Inz('Y')
         D Chr8            S             08
         D ChrField3       S             02
         D ChrField4       S             02
         D CmdString       S            256
         D CmdLength       S             15  5
         D CurDayofWeek    S             12    Inz(*blanks)
         D DayOfWeek       S             07  0
         D Signed          S             07S  0
         D DayOfWeekTxt    S             12    Inz(*blanks)
         D ISOdate         S               D
         D Len             S             03  0
         D ScreenError     S              1
    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
      Confusion.... Convert RPGLE code To RPG400

      I have to convert the code from RPGLE to RPG400. My code already have D spec (RPGLE) and i have to convert it to RPG III (or RPG400 whatr ever they call it).


      Thanks
      SAM

      Comment


      • #4
        ummm what

        D specs have been around for years ..... you are converting current code to primative code? Why?


        search for RPGII I-spec there may still be something on the web...Pre 1998???

        Code:
          *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8
          FFilenameIPEAF....RlenLKlAIOvKlocEDevice+......Kexit++Entry+A....U1........
          FARPCM   IP  E                    DISK
        
          IRcdname+....In............................................................
          IARPCM1      01
        
          I..............Ext-field+......................Field+L1M1..PlMnZr..........
          I                                              ARCUSTL6
        
        
          *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+
         FFilename++IPEASFRlen+LKlen+AIDevice+.File_continuation++++++++++++++++++++Comme
         FARPCM     IP   E             DISK
        
         IRcdname+++....Ri..........................................................Comme
         IARPCM1        01
        
         I..............Ext-field+..................Field+++++++++L1M1..PlMnZr......Comme
         I                                          ARCUST        L6
        --------------------------------------------------------------------------------
          An Introduction to ILE RPG: Part 3
         Figure   2 I-spec Program Described File
        
           *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8
          IFilenameSqNORiPos1NCCPos2NCCPos3NCC.......................................
          IARTRAN  NS  01   1 CA
          I       OR   02   1 CC
        
          I....................................PFromTo++DFldnmeL1M1FrPlMnZr.........
          I                                        1   1 TRCODE
          I                                        2   80TRCUST
          I                                        9  16 TRDATE
          I                                    P  17  212TRAMT
        
        
          *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+
         IFilename++SqNORiPos1+NCCPos2+NCCPos3+NCC..................................Comme
         IARTRAN    NS  01    1 CA
         I         OR   02    1 CC
        
         I........................Fmt+SPFrom+To+++DcField+++++++++L1M1FrPlMnZr......Comme
         I                                  1    1  TRCODE
         I                                  2    8 0TRCUST
         I                        *MDY/D    9   16  TRDATE
         I                             P   17   21 2TRAMT
        Thanks
        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


        • #5
          Conversion RPGILE to RPG400

          Yes, i had to convert current code to primative code becoz my org. have a java converter tool which converts RPG to JAVA. That code only converts RPG400 not ILE, that is why we have to convert the present code to RPG400 so that it can be converted to java.



          Thanks for the help
          SAM

          Comment


          • #6
            But RPG400 had d specs

            RPG400 supports D specs why change this?

            Anyway doesnt sound very fun.....Good luck

            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


            • #7
              In answer to your original question -

              Work fields are defined on the C-spec result field. You can use any operation, such as Z-ADD, ADD, SUB, MOVE, etc -- just enter the field length and decimal positions in the appropriate cols after the result field. If you leave the decimals field blank, it is a char field.

              Work fields can also be defined by a special C-spec with the DEFINE opcode, which allows you to define a field "like" another field.

              All fields defined are global thoughout all subroutines.

              Comment

              Working...
              X