ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

program parameter passing

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

  • program parameter passing

    Hi all,

    I have a program with two parameters. The parameters are declared numeric inside the rpg program. I have compiled with no errors but when i call the program interactively in the command line, i get a decimal data error. I tried to debug the program and have found out that only the first variable has the correct value, the second variable have a zero value in it:

    Call mypgm parm(12345 100)

    I resort to declaring the variables in rpg as character and passing character value and then move the values to a numeric. Is this the only way to resolve this or do you have any better way? thanks.

  • #2
    Re: program parameter passing

    how did you declare the numeric variables zoned or packed?

    Comment


    • #3
      Re: program parameter passing

      if you define all as 15,5 then you will not have this issue.

      then inside your called program eval them to the correct size.


      or pass HEX


      or create a command to test with when calling interactive.

      Hello Nicolas!
      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


      • #4
        Re: program parameter passing

        If you are passing RPG to RPG, you don't need to worry about the 15,5. But your parameters must be both defined as PACKED decimal. If you attempt to pass or receive zoned decimal, you will get data decimal errors. RPG-IV always assumes numeric data is packed when passing parms this way.

        Comment


        • #5
          Re: program parameter passing

          If those decimals are packed you can call your program for the command line...

          CALL PGM(MYPROGRAM) PARM(X'12345F' X'987F')

          If your numeric values are an even number of digits then you must add an extra 0 to the start of the string.

          Comment


          • #6
            Re: program parameter passing

            Thanks all for your replies.

            I declared my variables as packed. Actually i just used the like keyword in the D specs to copy the type from a field in one of the files. It is declared as packed 9,0 and 5,0 respectively for the 2 variables.

            Yes, I got no problem using the program calling it from another rpg as they are declared the same. It is just when i tried to test it in the command line, i got the decimal data error.

            I used the approach i learned from previous rpg programmers' programs declaring character variables to avoid data decimal errors. Is this approach good?

            Comment


            • #7
              Re: program parameter passing

              i'd just create a command so it passes the numeric values as expected.
              Code:
                     CMD        PROMPT('my program')                       
                     PARM       KWD(PARM1) TYPE(*DEC) LEN(9) MIN(1) +      
                                  PROMPT('first parm')                     
                     PARM       KWD(PARM2) TYPE(*DEC) LEN(5) MIN(1) +      
                                  PROMPT('second parm')
              after you finish testing just delete the command
              I'm not anti-social, I just don't like people -Tommy Holden

              Comment


              • #8
                Re: program parameter passing

                Or you could

                CALL PGM(your_pgm) PARM(x'123456789F' x'12345F')

                Make sure you replace the numeric values and that they are 9 and 5 digits respectively for example, if you want to pass 3645 and 23 as your parms you would..

                CALL PGM(your_pgm) PARM(x'000003645F' x'00023F')

                When you are passing numerics you have to pass as Hex to avoid the decimal data errors.

                Comment


                • #9
                  Re: program parameter passing

                  What Is The Syntax In rpg Program To Accept Parameter From Clp.

                  Comment


                  • #10
                    Re: program parameter passing

                    Code:
                    *Entry        Plist                          
                                  Parm                    fld1 
                                  Parm                    fld2
                    Regards

                    Kit
                    http://www.ecofitonline.com
                    DeskfIT - ChangefIT - XrefIT
                    ___________________________________
                    There are only 3 kinds of people -
                    Those that can count and those that can't.

                    Comment


                    • #11
                      Re: program parameter passing

                      Originally posted by arrow483 View Post
                      If you are passing RPG to RPG, you don't need to worry about the 15,5. But your parameters must be both defined as PACKED decimal. If you attempt to pass or receive zoned decimal, you will get data decimal errors. RPG-IV always assumes numeric data is packed when passing parms this way.
                      Uh oh -- I've got zoned all over the place when going from RPG to RPG. Primarily in service pgms where the prototypes are defined with the Const keyword. The return variables are also zoned.
                      Example:
                      Code:
                       D CYMDFromMDY     PR             8S 0        
                       D   MDYDate                      6S 0 Const
                      I hope this stuff isn't going to come back to haunt me at some time in the future.
                      http://www.linkedin.com/in/chippermiller

                      Comment


                      • #12
                        Re: program parameter passing

                        [
                        I hope this stuff isn't going to come back to haunt me at some time in the future.
                        Protypes are supposed to handle all this stuff properly. Its the older CALL/PARM that causes trouble.

                        Comment


                        • #13
                          Re: program parameter passing

                          Does anybody know how to make a prototype for *ENTRY parameters?

                          Comment


                          • #14
                            Re: program parameter passing

                            The name of the prototype is TWO

                            PHP Code:
                                  //
                                  //  entry plist
                                  //

                                 
                            d TWO             pr
                                 d  injob                        10
                                 d  inuser                       10
                                 d  instatus                     10

                                 d TWO             pi
                                 d  injob                        10
                                 d  inuser                       10
                                 d  instatus                     10 
                            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


                            • #15
                              Re: program parameter passing

                              That works. Thanks

                              Comment

                              Working...
                              X