Programs Let's call the program.
Try CALL a simple CL program with no parameters.
MYLIB/SMPL010C.CLLE
PGM
SNDMSG MSG('SMPL010C was called') TOMSGQ(*SYSOPR)
ENDPGM
Programs.JS
app.get("/smpl010c", function (req, res, next) {
var SMPL010C = pool.pgm('SMPL010C', []);
SMPL010C({}).then(
function (result) {
res.send(result);
});
});
There is one restriction on calling a program. That is, ** there is always a program to execute in the library list **. The following were all NG.
var SMPL010C = pool.pgm('MYLIB/SMPL010C', []);
var SMPL010C = pool.pgm('MYLIB.SMPL010C', []);
var SMPL010C = pool.pgm('/QSYS.LIB/MYLIB.LIB/SMPL010C.PGM', []);
Try to CALL RPGLE with parameters.
MYLIB/SMPL011R.SQLRPGLE
*
* CRTSQLRPGI OBJ(MYLIB/SMPL011R) SRCFILE(MYLIB/QRPGLESRC) DBGVIEW(*SOURCE)
*
H DFTACTGRP(*NO)
D main PR EXTPGM('SMPL011R')
D 3P 0
D 12A
D 12A
D 40A
D 7P 3
D main PI
D id 3P 0
D lname 12A
D fname 12A
D prof 40A
D tokuten 7P 3
D stmt S 512A
/free
stmt = 'insert into member' +
' values(?, ?, ?, ?, ?)';
exec sql prepare s1 from :stmt;
exec sql execute s1
using :id, :lname, :fname, :prof, :tokuten;
tokuten = tokuten + 100;
*inlr = *on;
return ;
/end-free
Programs.JS
app.get("/smpl011r", function (req, res, next) {
var SMPL011R = pool.pgm('smpl011r', [
{ type: 'DECIMAL', precision: 3, scale: 0, name: 'id' },
{ type: 'CHAR', precision: 12, scale: 0, name: 'lname' },
{ type: 'CHAR', precision: 12, scale: 0, name: 'fname' },
{ type: 'CHAR', precision: 40, scale: 0, name: 'prof' },
{ type: 'DECIMAL', precision: 7, scale: 3, name: 'tokuten' }
]);
SMPL011R({
id: 120,
lname: 'Date',
fname: 'Masamune',
prof : 'Appeared in white costume.',
tokuten: 10
}).then(function (result) {
res.send(result);
});
});
However, this program does not work properly. When I debugged SMPL011R to investigate the cause, I found that the Japanese parameters were not passed correctly.
So, I will try to fix the Java source of node-jt400. Get the source from github.
git clone [email protected]:tryggingamidstodin/node-jt400.git mynode-jt400
The source to be modified is \ java \ src \ nodejt400 \ Pgm.java.
Pgm.java
public TextPgmParam(String name, Props paramDef)
{
super(name, paramDef);
parser = new AS400Text(paramDef.getFirstInt("size", "precision"), "Cp871");
}
Cp871 seems to be doing something wrong, so I did the following:
Pgm.java
public TextPgmParam(String name, Props paramDef)
{
super(name, paramDef);
parser = new AS400Text(paramDef.getFirstInt("size", "precision"));
}
After modifying the source, create a new jt400wrap.jar and replace jt400wrap.jar in \ myfolder \ node_modules \ node-jt400 \ java \ lib.
I ran it again and debugged it in the same place. This time the parameters are passed correctly.
The parameter "tokuten" has been added 100. It seems that the return value is also taken.
The poster does not take any responsibility for the source modification. Please do so at your own risk.
Added on December 28, 2017 I put the pre-built jt400wrap.jar in here.
Recommended Posts