Last active
April 23, 2019 20:49
-
-
Save jkyeung/d88cd6220f31312796bd408dda36a90d to your computer and use it in GitHub Desktop.
Problem with iPgm parameters in python-itoolkit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itoolkit import iToolKit, iCmd, iPgm, iData | |
from itoolkit.transport import DatabaseTransport | |
from localutils import odbc_connect | |
def program1(conn, in1): | |
trans = DatabaseTransport(conn) | |
itool = iToolKit(irow=False) | |
itool.clear() | |
itool.add(iPgm('pgm', 'SPLIT', {'lib': 'LIB1'}) | |
.addParm(iData('text', '40a', in1)) | |
.addParm(iData('left', '25a', '')) # output | |
.addParm(iData('right', '25a', ''))) # output | |
itool.call(trans) | |
out = itool.dict_out('pgm') | |
return out | |
def program2(conn, in1, in2): | |
trans = DatabaseTransport(conn) | |
itool = iToolKit(irow=False) | |
itool.clear() | |
itool.add(iPgm('10', 'SETUPLIBL', {'lib': 'LIB2'})) | |
itool.call(trans) | |
print(itool.dict_out('10')) | |
itool.clear() | |
itool.add(iPgm('20', 'MATCH', {'lib': 'LIB1'}) | |
.addParm(iData('id', '6p0', str(in1))) | |
.addParm(iData('text', '40a', in2)) | |
.addParm(iData('seq', '3p0', '')) # output | |
.addParm(iData('first', '15a', '')) # output | |
.addParm(iData('last', '25a', '')) # output | |
.addParm(iData('title', '35a', '')) # output | |
.addParm(iData('email', '50a', '')) # output | |
.addParm(iData('retcd', '3a', ''))) # output | |
itool.call(trans) | |
out = itool.dict_out('20') | |
return out | |
conn = odbc_connect() | |
# This runs fine. | |
print(program1(conn, 'James Smith')) | |
# This fails because SETUPLIBL is called with 3 parameters instead of 0. | |
print(program2(conn, 1234, 'Victoria Rogers')) | |
# After answering 'C' to the message waiting on the i, execution continues, | |
# with the following line completing without errors. | |
print(program2(conn, 1234, 'Vicky Rodgers')) | |
# But then in the next line, SETUPLIBL fails again; though the library list | |
# has already been set up from before, so MATCH completes normally, and the | |
# function returns without any action needed on the i. | |
print(program2(conn, 1234, 'Vicky Rodgers')) | |
print('Done.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment