%parms gives incorrect value

Issue #4 resolved
Teemu Halmela created an issue

%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}]}]}

Comments (6)

  1. Teemu Halmela reporter

    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.

  2. Former user Account Deleted

    Ok, I added support for nopass.

    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)
    
  3. Teemu Halmela reporter

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

    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 🎃

  4. Former user Account Deleted

    i forget ILE interface name

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

    • QZRUCLSP Call Service Program Procedure (QZRUCLSP) API ... matching same pattern as our 'horrible' toolkit interface ... so ... now you know why they limited to 8 parameters (welcome to a real sausage factory).

    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.

  5. Teemu Halmela reporter

    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.

  6. Log in to comment