IBM / db2sock-ibmi

An asynchronous PASE Db2 and IBM i integration library
MIT License
4 stars 7 forks source link

PGM Call JSON Output Issues #9

Closed kadler closed 6 years ago

kadler commented 6 years ago

Original report by Danny Roessner (Bitbucket: droessner, GitHub: danny-hcs).


I’m not sure if I’m understanding the “by” functionality correctly or if this is incomplete, but when I add a “by”:”in” config to a parameter it is still included in the output. For example, I send something like {"s":{"name":"INPUT","type":"10a","value":"DATA","by":"in"}} and the output passes "pgm":["TEST","DANNY",{"INPUT":"DATA"}]. I would think if I specify "in" it should not be in the output.

Additionally, I have a simple RPG program that just returns a string. The config I’m sending for the parm is {"s":{"name":"RTRNCD","type":"8a","by":"out”}}. The RPG code is setting RTRNCD to an empty string, but the JSON output I’m getting for this parameter is {"RTRNCD":{}}. I would expect it to be {"RTRNCD":""}

kadler commented 6 years ago

Original comment by Danny Roessner (Bitbucket: droessner, GitHub: danny-hcs).


Tested various PGM calls and have not been able to reproduce the 2 issues. Marking as resolved.

kadler commented 6 years ago

Original comment by Danny Roessner (Bitbucket: droessner, GitHub: danny-hcs).


Thanks Tony! Appreciate the quick turn-around. I will definitely run some thorough tests and will close the issue out when ready.

kadler commented 6 years ago

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


{"by":"in/out/both"}

Ok. I added "by":"in", to remove input params from the output json returned.

Yips Super Driver test driver - 1.1.1-sg6 toolkit add "by":"in" remove output

#!bash

=============================
test1000_sql400json64 ../json/j07411_srvpgm_value_rainint1_by_in
=============================
input(5000000):
{"pgm":[{"name":"RAINSRV", "lib":"DB2JSON", "func":"RAININT1"},
        {"s":[{"name":"a1", "type":"3i0", "value":1, "by":"val"},
              {"name":"a2", "type":"3i0", "value":2, "by":"val"},
              {"name":"a3", "type":"3i0", "value":3, "by":"val"},
              {"name":"a4", "type":"3i0", "value":4, "by":"val"},
              {"name":"o1", "type":"3i0", "value":5, "by":"in"},
              {"name":"o2", "type":"3i0", "value":6, "by":"in"},
              {"name":"o3", "type":"3i0", "value":7, "by":"both"},
              {"name":"o4", "type":"3i0", "value":8, "by":"in"}
             ]}
       ]}

output(98):
{"script":[{"pgm":["RAINSRV","DB2JSON","RAININT1",
{"a1":1},{"a2":2},{"a3":3},{"a4":4},
{"o3":3}]}]}

Note: o1, o2, o4 are missing, only o3 is output

result:
success (0)

Also works for ds structures (i think).

#!bash

bash-4.3$ ./test1000_sql400json32 ../json/j0115_srvpgm_hello_ds_by_in
input(5000000):
{"pgm":[{"name":"HELLOSRV", "lib":"DB2JSON", "func":"HELLODS"},
        {"ds":[{"s":{"name":"char", "type":"128a", "value":"Hi there"}},{"name":"parm","by":"in"}]},
        {"ds":[{"s":{"name":"char", "type":"128a", "value":"Hi back"}},{"name":"retn","by":"return"}]}
       ]}

output(105):
{"script":[{"pgm":["HELLOSRV","DB2JSON","HELLODS",
{"parm":[]},
{"retn":[{"char":"Hello World Again"}]}]}]}

result:
success (0)

Probably needs more testing ... that you could help out.

kadler commented 6 years ago

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


"RTRNCD":{} to "RTRNCD":""

Ok. I changed db2sock toolkit empty string.

#!bash

=============================
test1000_sql400json32 ../json/j0180_pgm_hamela03-ds-rpg-occurs
=============================
input(5000000):
{"pgm":[
    {"name":"HAMELA03",  "lib":"DB2JSON"},
    {"s": [
        {"name":"Parm1", "type":"1a", "value":""},
        {"name":"Parm2", "type":"18a", "value":"äöÄÖåÅáÁàÀ"},
        {"name":"Parm3", "type":"2a", "value":""},
        {"name":"Parm4", "type":"10a", "value":""},
        {"name":"Arr1Count", "type":"3s0", "value":0}
    ]},
kadler commented 6 years ago

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


... if I specify "in" it should not be in the output.

Correct. However, {"by":"in/out"} are not implemented yet in db2sock toolkit.

BTW -- Only {"by":"return"} is implemented (so far), allow srvpgm to return aggregate data (dcl-pi *N likeds(hello_ds_t);).

"RTRNCD":{}

Return '{}' is a valid for json "empty" object. Mmm ... however ... perhaps json empty string is not considered a json empty object (below).

#!json

Valid minimal JSON strings are

The empty object '{}'
The empty array '[]'
The string that is empty '""'
A number e.g. '123.4'
The boolean value true 'true'
The boolean value false 'false'
The null value 'null'

status/outlook

I will look into both issues.