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.
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
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
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
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.
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
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??
Neil if right... I was going to say the same thing.
4P 0 means 4 digits, packed.
1234
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'