IBM / python-itoolkit

itoolkit is a Python interface to the XMLSERVICE toolkit for the IBM i platform.
MIT License
19 stars 13 forks source link

Passing variables using addParm #42

Closed arun-01 closed 4 years ago

arun-01 commented 4 years ago

Hi,

is there a way to pass variables with addParm of ipgm call instead of quoted values. I checked the documentation, but the examples show using quoted strings for passing values.

itool.add(
  iPgm('mykey','MYPGM')
    .addParm(iData('parm1','10p0','3458589'))
    .addParm(iData('parm2','5p0','1253'))
)

For example in the above code I would like to use parm1 & parm2 values to be based on variables defined in my python script dynamically for each call instead of quoted values 345859 and 1253 from above.

I am using XMLSERVICE db2 call for above and running python 3.6.8 in virtual environment on V7R3 machine. Appreciate your suggestions/help.

Thanks, Arun

chrjorgensen commented 4 years ago

My guess would be that you substitute the literals with the name of your Python variables, eg.

itool.add(
  iPgm('mykey','MYPGM')
    .addParm(iData('parm1','10p0',python_var1))
    .addParm(iData('parm2','5p0',python_var2))
)
arun-01 commented 4 years ago

Hi, Thanks for your response. I already tried that way and it didn't work and throwing an error.

chrjorgensen commented 4 years ago

It worked for me when I passed a python variable as data to a char parameter.

If your python parameter is numeric, you could try and convert it using "str(num_py_var)".

arun-01 commented 4 years ago

Hi, I did try converting to string and it works. Thanks a lot for your assistance. So the way to pass numeric values is by casting them. Arun

kadler commented 4 years ago

I've opened #43 to fix this and make clear what the issue is.