Midrange News for the IBM i Community


Posted by: Mukund Kallapur
Decimal Data Error while calling a RPG IV Program
has no ratings.
Published: 15 Dec 2011
Revised: 23 Jan 2013 - 1519 days ago
Last viewed on: 22 Mar 2017 (7783 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Decimal Data Error while calling a RPG IV Program Published by: Mukund Kallapur on 15 Dec 2011 view comments(6)

Hello All,

Below is my RPG IV module. It is a simple calculation and has 1 sub procedure with 1 Parameter. The parameter is  numeric. When i call a program with this module and pass a numeric parameter, in spite of giving the parameter in HEX Format, I am getting Decimal Data Error.

 

//Code

 

DShiftCalc        pr             1  0                

DNoHours                         4p 0                

DHrs              s              4  0                

DShiftAll         s              4  0                

C     *entry        plist                            

C                   parm                    Hrs      

C                   eval      ShiftAll=ShiftCalc(Hrs)

C     ShiftAll      dsply                            

C                   eval      *INLR=*ON              

PShiftCalc        B                                  

DShiftCalc        pi             1  0                

DHrs                             4p 0                

DMoney            s              4  0                

C     Hrs           ifgt      40                     

C                   eval      Money=Money+2500       

C                   return    Money                  

C                   endif                                               

PShiftCalc        e      

 

\\

 

Later i call a Program TEST1. The call statement is as follows.

CALL PGM(TEST1) PARM(X'040F')

 

This gives a decimal data error.

 

Kindly assist

 

                                             

 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: DeepakD
Premium member *
India
Comment on: Decimal Data Error while calling a RPG IV Program
Posted: 5 years 3 months 8 days 14 hours 54 minutes ago

Why not define Hrs as Char field & call CALL PGM(TEST1) PARM('40')

TEST1 can convert Char '40' to Num 40 & then call procedure.

DD

Posted by: MukundGK
Premium member *
Comment on: Decimal Data Error while calling a RPG IV Program
Posted: 5 years 3 months 8 days 14 hours 32 minutes ago

Dear Deepak,

 

Thanks for your swift reply. But actually I want to learn how to pass numeric parameters in the HEX format. That is what I am looking for. This idea had also struck to me but later I thought why to avoid any problem for which I am unable to find the solution, even though there is a solution. I hope you understand.

One more point is that, in TEST1 there is no Code. I have just created TEST1 using CRTPGM with the above module (SUBP2) in it. Once that object got successfully got created I call that object i.e, TEST1.

Thanks

Posted by: Paulster
Premium member *
Sweden and The Netherlands
Comment on: Decimal Data Error while calling a RPG IV Program
Posted: 5 years 3 months 8 days 11 hours 41 minutes ago
Edited: Thu, 15 Dec, 2011 at 05:21:32 (1924 days ago)

Hi M,

 

Looks like the parameter on your call to program test1 is incorrect. Start debug on program test1, call it as described and check the value for the parameter on the first executable line (the eval). That ought to give you insight on what's causing the dde.

 

Regards,

Paulster

BTW:
Get back to me if the bonus of 2500 is in USD, I just might apply for the job.

Posted by: DeepakD
Premium member *
India
Comment on: Decimal Data Error while calling a RPG IV Program
Posted: 5 years 3 months 8 days 10 hours 22 minutes ago

Hi

I guess you need to call TEST1 differently.

Since this is a 4,0 packed field and you are passing HEX value on command line, the call statement should be :

call test1 parm(x'00040F')

HTH

DD

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: Decimal Data Error while calling a RPG IV Program
Posted: 5 years 3 months 8 days 9 hours 42 minutes ago

It's much easier to have input parameters as odd-length packed, you don't have to remember which bits are ignored.  For a 5,0packed field you pass 5 digits and an F, thus x'12345F' will result in a value of 12345 in the packed field.  For a 4,0packed I cannot remember if x'00040F' will result in a value of 4 or 40!!  Either way you still have to pass 5 digits and a F for 4,0packed field.

Another obvious question, since you are using procedure interfaces for procedures, and are obviously educated in their use - why are you still using *entry plists for the program??

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Decimal Data Error while calling a RPG IV Program
Posted: 5 years 3 months 8 days 5 hours 33 minutes ago
Edited: Thu, 15 Dec, 2011 at 11:28:58 (1924 days ago)

Neil if right... I was going to say the same thing.

4P 0 means 4 digits, packed.

1234

To calculate a packed field size:

If the length is even (divisible by 2), then the size is:

(Len + 2) / 2

If the length is odd, then the size is:

(Len + 1) / 2

Yours is 4 so,

(4 + 2) / 2 = 3

The packed size is 3, so to convert this to hex it would be X'00000F'