phelgren / rpg-node

Using node.js and RPGLE in peaceful coexistence

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node JS Calling RPGLE

sheikhifti opened this issue · comments

In below mention program I want to use file and also want to call another RPGLE program but it is hanging not working or not given any error. Please help or if you have any example please share. Thanks

Here is the code please advise.

**free
ctl-opt dftactgrp(*no);

dcl-pr zpgm5 extpgm;
dec1 char(2);
char1 char(35);
char2 char(50);
end-pr;
dcl-pi zpgm5;
dec1 char(2);
char1 char(35);
char2 char(50);
end-pi;

dcl-f ZPFILE usage(*input) keyed usropn;
dcl-s cid char(2);
cid = dec1;
open ZPFILE;
chain (cid) ZPFILE;

char1 = CUSNM ;
char2 = CUSEM ;
close ZPFILE;
return;

Node
var xt = require("itoolkit");
var conn = new xt.iConn("*LOCAL");

var pgm = new xt.iPgm("ZPGM5", {"lib":"IAWEBSRV"});
pgm.addParam("01", "2A");
pgm.addParam(" ", "35A");
pgm.addParam(" ", "50A");

conn.add(pgm.toXML());

conn.run(function (rsp) {
var results = xt.xmlToJson(rsp);
console.log(results);
results.forEach(function(result, index){
result.data.forEach(function(data, index2){
console.log("type:" + data.type + " value:" + data.value);
});
});
});

File
A UNIQUE
A R ZPREC
A CUSID 2A COLHDG('CUSTOMER ID')
A CUSNM 35A COLHDG('CUSTOMERS NAME')
A CUSEM 50A COLHDG('CUSTOMER EMAIL')
A K CUSID

This is taking a slightly different approach and at 7 years old, I probably need to update the sample code so it reflects the current open source support on I.

You may want to check into IBMiOSS on the ryver forum, they may have some insights for you (https://ryver.com/)