Snippets
Created by
Aaron Bartell
last modified
#---- Attempt #3 (fixed)---- This is now working with the latest PTFs (2016-08-19) This was done with node -v 4.4.6.
% node
>
> var db = require('/QOpenSys/QIBM/ProdData/OPS/Node4/os400/db2i/lib/db2')
undefined
> var xt = require('/QOpenSys/QIBM/ProdData/OPS/Node4/os400/xstoolkit/lib/itoolkit')
undefined
> var conn = new xt.iConn('*LOCAL')
undefined
> conn.debug(true)
undefined
> db.init()
undefined
> db.conn("*LOCAL")
undefined
> db.debug(true)
undefined
> conn.add(xt.iCmd("RTVJOBA USRLIBL(?) SYSLIBL(?)"))
undefined
> function cbJson(str) {
... console.log("The raw XML output --- ")
... console.log(str); // Print the raw XML output
... console.log("The formatted JSON output --- ")
... console.log(JSON.stringify(xt.xmlToJson(str), null, 4))
... }
undefined
> conn.run(cbJson)
============
INPUT XML
============
<?xml version='1.0'?><myscript><cmd exec='rexx' error='fast'>RTVJOBA USRLIBL(?) SYSLIBL(?)</cmd></myscript>
============
OUTPUT XML
============
SQLConnect: conn obj [3098a5b0] handler [3]
PrepareAsync().
SQL: call QXMLSERV.iPLUG512K(?,?,?,?)
uv_queue_work(PrepareAsyncAfter).
undefined
> BindParamAsync().
uv_queue_work(BindParamAsyncAfter).
Bind Parameter [1] = undefined
Bind Parameter [2] = undefined
Bind Parameter [3] = <?xml version='1.0'?><myscript><cmd exec='rexx' error='fast'>RTVJOBA USRLIBL(?) SYSLIBL(?)</cmd></myscript>
Bind Parameter [4] =
ExecuteAsync: conn obj [3098a5b0] handler [3]
uv_queue_work(ExecuteAsyncAfter).
SQLExecute() rc=0.
The raw XML output ---
<?xml version='1.0'?><myscript><cmd exec='rexx' error='fast'><success>+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)</success>
<row>
<data desc='USRLIBL'>QGPL QTEMP</data>
</row>
<row>
<data desc='SYSLIBL'>QSYS QSYS2 QHLPSYS QUSRSYS</data>
</row>
</cmd>
</myscript>
The formatted JSON output ---
[
{
"type": "cmd",
"success": true,
"cmd": "RTVJOBA USRLIBL(?) SYSLIBL(?)",
"data": [
{
"name": "USRLIBL",
"value": "QGPL QTEMP"
},
{
"name": "SYSLIBL",
"value": "QSYS QSYS2 QHLPSYS QUSRSYS"
}
]
}
]
SQLDisconnect: conn obj [3098a5b0] handler [3]
SQLRowCount() rowCount=-891239599.
SQLNumResultCols() colCount=0.
#---- Attempt #2 ---- First, make the following change to /QOpenSys/QIBM/ProdData/Node/os400/xstoolkit/lib/istoredp.js: https://www.diffchecker.com/johcbf9r
Then run this code:
var db = require('/QOpenSys/QIBM/ProdData/Node/os400/db2i/lib/db2')
var xt = require('/QOpenSys/QIBM/ProdData/Node/os400/xstoolkit/lib/itoolkit')
var conn = new xt.iConn('*LOCAL')
conn.debug(true)
db.init()
db.conn("*LOCAL")
db.debug(true)
conn.add(xt.iCmd("RTVJOBA USRLIBL(?) SYSLIBL(?)"))
function cbJson(str) {
console.log("The raw XML output --- ")
console.log(str); // Print the raw XML output
console.log("The formatted JSON output --- ")
console.log(JSON.stringify(xt.xmlToJson(str), null, 4))
}
conn.run(cbJson)
That produces this error:
<errnoxml>1100012</errnoxml>
<xmlerrmsg><![CDATA[XML run cmd failed]]></xmlerrmsg>
<xmlhint><![CDATA[RTVJOBA USRLIBL(?) SYSLIBL(?)]]></xmlhint>
</error>
<error>
<errnoile>3101</errnoile>
<errnoilemsg><![CDATA[A non-recoverable I/O error occurred.]]></errnoilemsg>
<cpf>CPF4102</cpf>
<status>3101</status>
<errnoxml>1100012</errnoxml>
<xmlerrmsg><![CDATA[XML run cmd failed]]></xmlerrmsg>
<xmlhint><![CDATA[RTVJOBA USRLIBL(?) SYSLIBL(?)]]></xmlhint>
</error>
<jobinfo>
<jobipc>undefined</jobipc>
<jobipcskey>FFFFFFFF</jobipcskey>
<jobname>QP0ZSPWP</jobname>
<jobuser>QSECOFR</jobuser>
<jobnbr>860412</jobnbr>
<jobsts>*ACTIVE</jobsts>
<curuser>USRSHGAN</curuser>
<ccsid>37</ccsid>
<dftccsid>37</dftccsid>
<paseccsid>819</paseccsid>
<langid>ENU</langid>
<cntryid>US</cntryid>
<sbsname>QUSRWRK</sbsname>
<sbslib>QSYS</sbslib>
<curlib></curlib>
<syslibl>QSYS QSYS2 QHLPSYS QUSRSYS</syslibl>
<usrlibl>QGPL QTEMP</usrlibl>
<jobcpffind>see error list, not log scan</jobcpffind>
</jobinfo>
</cmd>
</myscript>
The formatted JSON output ---
[
{
"type": "cmd",
"success": false
}
]
SQLRowCount() rc=0.
SQLNumResultCols() rc=0.
[Error: SQLSTATE=PAERR SQLCODE=-1 SQLFreeEnv() failed.]
undefined
#---- Attempt #1 ----
var db = require('/QOpenSys/QIBM/ProdData/OPS/Node4/os400/db2i/lib/db2')
var xt = require('/QOpenSys/QIBM/ProdData/OPS/Node4/os400/xstoolkit/lib/itoolkit')
var conn = new xt.iConn('*LOCAL')
conn.debug(true)
db.init()
db.conn("*LOCAL")
db.debug(true)
conn.add(xt.iCmd("RTVJOBA USRLIBL(?) SYSLIBL(?)"))
function cbJson(str) {
console.log("The raw XML output --- ")
console.log(str);
console.log("The formatted JSON output --- ")
console.log(JSON.stringify(xt.xmlToJson(str), null, 4))
}
conn.run(cbJson)
That produces:
============
INPUT XML
============
<?xml version='1.0'?><myscript><cmd exec='rexx' error='fast'>RTVJOBA USRLIBL(?) SYSLIBL(?)</cmd></myscript>
============
OUTPUT XML
============
SetEnvAttr() attr = 10004, value = 1, rc = -1
**** ERROR *****
SQLSTATE: HY010
Native Error Code: -99999
Error occurred in SQL Call Level Interface
[Error: SQLSTATE=HY010 SQLCODE=-99999 Error occurred in SQL Call Level Interface]
Comments (1)
You can clone a snippet to your computer for local editing. Learn more.
The output you've shown for Attempt #2 looks like what I'm currently getting when I try the RTVJOBA example for python-itoolkit in my Python Litmis Space. That is, if I navigate to the
sample
directory within theitoolkit
installation and dopython icmd_rtvjoba.py
, I see output that basically amounts to what you've shown.Without easy access to the native i side, I cannot diagnose the problem. The output is strongly suggesting there is a CPF4102 error, which is normally that a file member isn't found.
Have you found a resolution to this?