ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

parameter value in debug mode

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

  • parameter value in debug mode

    hi,

    there is a parameter in rpgle program with 6 length and with 0 decimal position when trying to debug this program by calling it with that paramter value for example like ''005367'
    then it's being passed as 5whiterectanglebox3whiterectanglebox6whiterectangl ebox. i checked it's value like this in debug mode why is it happening so?

    thanks..

  • #2
    I usually pass parameters as CHAR, then convert them to numeric in the called program. I recall problems passing numeric Parms, but don't remember the specifics. Maybe packed was the problem ?
    Last edited by MFisher; February 14, 2022, 09:45 AM.

    Comment


    • #3
      How to do this here for this case i mean if i am passing it for this numeric field wrongly then what should be the correct way to pass it?

      thanks..

      Comment


      • #4
        Program A: Move numeric field FIELD_N to Char (Alpha) field FIELD_C
        Pass Char field FIELD_C parameter to Program B
        Program B, move Char field FIELD_C to Numeric field FIELD_N

        I didn't understand your problem in original post, so not sure if this is a solution.

        Comment


        • #5
          i simply meant to ask that if i have some parameters defined in a rpgle program as *entry plist
          parm p1 6 0

          here this p1 is defined like above when trying to debug this program i am calling this program like call rpg1 parm('005367') then when i am inside debug session then if i do eval on this p1 then this junk value i see like mentioned earlier so is there anything i am doing wrong here?


          Thanks..

          Comment


          • #6
            Try this:
            Code:
            call rpg1 parm(x'0005367F')

            Comment


            • #7
              Why to put this x and F here? in hex format?


              Thanks..

              Comment


              • #8
                thanks it's working but why did it work in this special way why did it not work the way i was trying?


                Thanks..

                Comment


                • #9
                  First things first. A called program is expecting to receive a pointer to the data. And that data is assumed to be of the length and data type defined.

                  When you pass parms from the command line the system has no idea what size or type the called program is expecting. As a result it relies on defaults. If it is given a numeric value it will format the data as a 15,5 packed value and pass a pointer to that. For character fields it will pass a pointer to a 32 char field or the actual length whichever is longer.

                  This is why the hack of using hex values works - because although a pointer to a 32 character field will still be passed, the expected data is at the start of that field (followed by blanks).

                  In your case you passed a character field (you enclosed the number in quotes) which would have been OK had the expected parameter been zoned numeric (it would have been wrong but it would have worked for the same reason the hex hack works) - but your parameter is expected to be packed decimal so instead of receiving x'0005367F' as expected your program received x'F0F0F5F3F6F740404040...' - and that is not a valid packed number.

                  The best way to fix this is to create a command to call your program and that will take care of the conversion - or use a small RPG program that perhaps uses DSPLY to receive a value for the parm and then calls the program to be tested. Alternatively always code your programs to expect packed 15,5!

                  Comment


                  • #10
                    In my previous “Fundamentals” tips, I discussed the importance of making sure parameters are the correct size and how to correctly handle omitted parameters. In this tip I want to address what has to be the most frequently asked question about parameters. The most frequently asked parameter question comes in many forms, such as: “How

                    Comment


                    • #11
                      Thanks Ted - I knew I'd written that up but could not find it, Having a bad google day I guess!

                      Comment


                      • #12
                        How cn it be coded inside the RPG or cl program for each different such 6p 0 numeric values also what does it mean expect packed 15,5! where as that specific parameter is of packed data type with 6 length and 0 decimal position only ?

                        Thanks..

                        Comment


                        • John192
                          John192 commented
                          Editing a comment
                          the hex value of 005367 is 14F7 as per this link:-https://www.rapidtables.com/convert/number/decimal-to-hex.html

                        • John192
                          John192 commented
                          Editing a comment
                          so why x'0005367F' this value was passed as hex number equivalent to 005367?

                      • #13
                        Did you read the link that ted provided? It explains it all pretty clearly.

                        There are 4 type of numerics supported by IBM i. Packed, Float, Binary Integer, and Zoned.

                        Packed - which is what we are talking about here - uses four bits (known as a nibble or nyble) to represent each digit. The sign is in the rightmost nibble. So the 6 digit number 123456 is represented in hex as 01 22 35 6F.

                        You need to read up on that.

                        Comment


                        • #14
                          John192, I strongly recommend creating a command to call the program, even if you are just calling it from the command line to test it. It's very easy to create a simple command. The article that Ted posted has an example that should be very easy to copy.

                          It will be much easier to test your program using the command than to test it by typing a hexadecimal value.

                          Comment


                          • John192
                            John192 commented
                            Editing a comment
                            how can we create such a command i below an example to create command ? it does not call any rpgle program like for example in my case where i was passing value from command line and calling my program then both of these things how could be possible with below example as per ted's link?

                            Code:
                            CMD
                            PARM       NBR1       TYPE(*DEC)   LEN(7 2)
                            PARM       SHORTCHAR  TYPE(*CHAR)  LEN(3)
                            PARM       KWD(NBR2)  TYPE(*DEC)   LEN(3)
                            PARM       LONGCHAR   TYPE(*CHAR)  LEN(60)
                            what will the member type of such a command as mentioned above how will it be call for example my RPGLE program name is 'ABC' which has such numeric data type 6p 0 then how will I call above command with respect to my program and parameter here?


                            Thanks...

                        • #15
                          thanks ,but in Ted's link also it is just explained for a single numeric value also what about if a file is having a field of type 6 p 0 (packed with zero decimal position and numeric value of length 6 ) which has such multiple values so at a one go how can we convert all these packed decimal to hexadecimal also how can we convert different numeric types :- 4 type of numerics supported by IBM i. Packed, Float, Binary Integer, and Zoned in to hexadecimal number ?

                          Comment


                          • John192
                            John192 commented
                            Editing a comment
                            also as mentioned in that link "Note however that this does not provide any assistance when dealing with zoned parameters since commands do not offer zoned as an available data type." so what about zoned parameters or both when parameters passed from a command within some CL type program or some small RPG type program and from command line ?


                            Thanks..
                        Working...
                        X