Page 1 of 1

TABLEMANAGER.callProgram with the new JSM Webserver.

Posted: 01 Sep 2021, 00:13
by jaimosky
HI,

I just wanted to know if anybody has used TABLEMANAGER.callProgram with the new JSM Webserver. Whenever I call this javascript function I get

Code: Select all

AXES.TableManager._oncallProgramOK: Error trapped - Attempt to invoke /agi/lua5/extservice_6.lua failure trapped by _oncallProgramFail
I have included in the AXES/AXES *JOBD all the necessary libraries to run the called program.

Thanks.

Jaime.

Re: TABLEMANAGER.callProgram with the new JSM Webserver.

Posted: 05 Oct 2021, 15:46
by Fairdinkum
Hi Jaime,

I'm not sure whether TABLEMANAGER.callProgram is availale in JSM, though, the Connector programCall() might be able to work instead. See the followings.

Firstly, prepare a sample CL program.
(Sample CL program)

Code: Select all

             PGM        PARM(&OBJ &TOOBJ &RESULT)

             DCL        VAR(&OBJ)   TYPE(*CHAR) LEN(64)
             DCL        VAR(&TOOBJ) TYPE(*CHAR) LEN(64)
             DCL        VAR(&RESULT) TYPE(*CHAR) LEN(1)

             CHGVAR     VAR(&RESULT) VALUE('0')

             CPY        OBJ(&OBJ) TOOBJ(&TOOBJ) REPLACE(*YES) +
                          OWNER(*KEEP)

             MONMSG     MSGID(CPF0000) EXEC(CHGVAR VAR(&RESULT) +
                          VALUE('9'))

             ENDPGM
This program just copies &OBJ to &TOOBJ. And if there is something wrong, 9 will be returned. Compile this code into AXESDEMO/CPYCL.


Secondly, add the following code into onSignOn to load some files so that programCall is executed from the aXes session.
(onSignOn)

Code: Select all

/*
 * プロジェクト名を取得 (Get definitionSet)
 */
USERENV.definitionSet = AXES.urlParameters.definitionset;

/*
 * プロトコルを取得 (Get Protocol)
 */
USERENV.protocol = document.location.protocol.toLowerCase();

/*
 * ホストのIP/ポートを取得 (Get IP/Port)
 */
USERENV.host = document.location.host;

/*
 * LUIコネクターをロード (Load LUI Connector)
 */
var urlPath = USERENV.protocol + "//" + USERENV.host;
if ( typeof LUICONNECTOR === "undefined" ) {
  $.getScript(
    urlPath + "/ws/lui-connector-min.js"
  ).done( console.log("lui-connector-min.js loaded.") );
}
if ( typeof LUIENCRYPT === "undefined" ) {
  $.getScript( 
    urlPath + "/ws/lui-encrypt-min.js"
  ).done( console.log("lui-encrypt-min.js loaded.") );
}
Thirdly, add the code below into a push button's onClick property.
(onClick)

Code: Select all

var params = {
  protocol: USERENV.protocol,
  host    : USERENV.host,
  user    : "lansa", /* must have *ALLOBJ as SPCAUT */
  pwd     : "lansa",
  // programCall(CPYCL)に受け渡すパラメータ
  prm1: "/home/tana/examplephoto.gif",
  prm2: "/home/tana/examplephoto2.gif",
  ret1: ""
};

console.log("params="+JSON.stringify(params));

programCall( params );

function programCall( p ){
  var host = { 
    endpoint: p.protocol + "//" + p.host + "/service/connector.jsp",
    profile:p.user,
    password:p.pwd
  };
  var service = {
    connector:"programcall", 
    object:"CPYCL", 
    parameters:[
      { name: "OBJ",    value:p.prm1 },
      { name: "TOOBJ",  value:p.prm2 },
      { name: "RESULT", value:p.ret1 }
    ]
  };
  response = LUICONNECTOR.execute ( host, service, null ) ;
  console.log( JSON.stringify(response));
  var ret = response.parameters[0].value ;
  if (ret === "0") {
    alert("Done!");
  }else{
    alert("Error!");
  }
}
*You might want to change "user", "pwd", "prm1" and "prm".


Lastly, add the following line into <connector name="programcall"> block, and then re-start the system.
(httpd.xml)

Code: Select all

<parameter name="object.call.CPYCL" value="{program:'AXESDEMO/CPYCL',parameters:[{name:'OBJ',length:64,encoding:'Cp5035'},{name:'TOOBJ',length:64,encoding:'Cp5035'},{name:'RESULT',type:'O',length:1}]}"/>

If the customization above is done properly, you will see something like the following video.
https://drive.google.com/file/d/14Nrb9P ... sp=sharing

HTH!

Regards,
Hide