kadler / db2sock-test

1 stars 0 forks source link

%parms gives incorrect value #4

Closed kadler closed 6 years ago

kadler commented 6 years ago

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


%parms() seems to give a value 128 although program gets fewer parameters. This probably has something to do with calling through stored procedure, but is there something that could be done about this? This might also be the reason why things don't crash although you don't give all the necessary parameters in the json.

     H AlwNull(*UsrCtl)

       dcl-pr Main extpgm;
         paramCount int(10);
         p1 char(5);
         p2 char(5) options(*nopass);
         p3 char(5) options(*nopass);
       end-pr;

       dcl-pi Main;
         paramCount int(10);
         p1 char(5);
         p2 char(5) options(*nopass);
         p3 char(5) options(*nopass);
       end-pi;
         paramCount = %parms();
       return;
input(271):
{"pgm":[
    {"name":"TPGM4", "lib":"DB2JSON"},
    {"s": [
        {"name":"paramCount", "type":"10i0", "value":0},
        {"name":"p1", "type":"5a", "value":""},
        {"name":"p2", "type":"5a", "value":""},
        {"name":"p3", "type":"5a", "value":""}
    ]}
]}

output(89): {"script":[{"pgm":["TPGM4","DB2JSON",{"paramCount":128},{"p1":{}},{"p2":{}},{"p3":{}}]}]}
input(222):
{"pgm":[
    {"name":"TPGM4", "lib":"DB2JSON"},
    {"s": [
        {"name":"paramCount", "type":"10i0", "value":0},
        {"name":"p1", "type":"5a", "value":""},
        {"name":"p2", "type":"5a", "value":""}
    ]}
]}

output(79): {"script":[{"pgm":["TPGM4","DB2JSON",{"paramCount":128},{"p1":{}},{"p2":{}}]}]}
input(174):
{"pgm":[
    {"name":"TPGM4", "lib":"DB2JSON"},
    {"s": [
        {"name":"paramCount", "type":"10i0", "value":0},
        {"name":"p1", "type":"5a", "value":""}
    ]}
]}

output(69): {"script":[{"pgm":["TPGM4","DB2JSON",{"paramCount":128},{"p1":{}}]}]}
input(126):
{"pgm":[
    {"name":"TPGM4", "lib":"DB2JSON"},
    {"s": [
        {"name":"paramCount", "type":"10i0", "value":0}
    ]}
]}

output(59): {"script":[{"pgm":["TPGM4","DB2JSON",{"paramCount":128}]}]}
kadler commented 6 years ago

Original comment by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


As the %parms now works correctly I'll resolve this issue.

kadler commented 6 years ago

Original comment by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


In any way I was trying to make fun of you. I was just trying to be snarky.

Of course I feel you should always be uneasy if you suddenly have to add 10 000 lines of code to your project. But

... and with some meta programming magic

No. Sorry. There is no meta data solution from above the MI.

by meta programming I meant you are generating all of this code using gen.py. So maintaining all those 10k lines is manageable and the amount of generated code doesn't matter that much.

I'm 100% sure you know these IBM systems better than me so I'll trust your judgment on these issues.

kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


i forget ILE interface name

I had to ask compiler guy what name of that interface was ...

BTW -- This is a 8 parm interface. Our toolkit 259 by reference (so far). However, we may limit pass by value to fewer than 259 for service programs.

kadler commented 6 years ago

Original comment by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


Yes, this seems to work now. And the solution is completely horrible :smiley:

So you just create a function for all of the parameter counts to a point? I hope RPG has a limit on parameter count. Solution isn't very elegant, but if it works... and with some meta programming magic you aren't losing your mind and all this nonsense is manageable.

And I'm not frustrated I'm just horrified :jack_o_lantern:

kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


Ok, I added support for nopass.

#!bash

bash-4.3$ ./test1000_sql400json32 j0191_pgm_hamela06-rpg-nopass-only-2
input(5000000):
{"pgm":[
    {"name":"HAMELA06", "lib":"DB2JSON"},
    {"s": [
        {"name":"paramCount", "type":"10i0", "value":0},
        {"name":"p1", "type":"5a", "value":""}
    ]}
]}

output(70):
{"script":[{"pgm":["HAMELA06","DB2JSON",{"paramCount":2},{"p1":{}}]}]}

result:
success (0)
kadler commented 6 years ago

Original comment by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


It's fine if there is a solution coming. This is something that won't matter in this testing phase. If this project ever gets to production status then it is needed.