xmlservice icon indicating copy to clipboard operation
xmlservice copied to clipboard

Itoolkit's iPgm - Library setup

Open deepakpenjarla opened this issue 5 years ago • 17 comments

iToolkit's iPgm is taking Library List from User's JOBD library list. Any way to give the library list in run time.?

I tried submitting the job with a JOBD which has a set of libraries but no use. When I console the result after run( ). I see below XML.

\n \n XML Toolkit 1.9.9\n \n 1100016\n \n ]]> \n \n \n 10000 05\n \n \n \n \n 1100016\n \n ]]> \n \n \n *NA\n FFFFFFFF\nQSQSRVR \n QUSER\n 266967\n *ACTIVE\n USER01\n 37\n 37\n 819\n ENU\n US\n QSYSWRK\n QSYS\n \n QSYS QSYS2 QHLPSYS QUSRSYS\n QTEMP LIBRARY1 LIBRARY2\n see log scan, not error list \n \n \nundefined

deepakpenjarla avatar Jan 22 '20 14:01 deepakpenjarla

@ThePrez Could you please help on this.?

deepakpenjarla avatar Jan 22 '20 14:01 deepakpenjarla

@deepakpenjarla

What if you ran CHGLIBL prior to calling your program?

What version of itoolkit are you using?

abmusse avatar Jan 22 '20 15:01 abmusse

@abmusse We are using itoolkit v0.1.6.

Library List of submitted Job (Node Jobs) is having the library list properly. Node Jobs :
QP0ZSPWT USER01 BATCHI ACTIVE PGM-sh
QP0ZSPWT USER01 BATCHI ACTIVE PGM-node
QZSHSH USER01 BATCHI ACTIVE PGM-QZSHSH

but it internally submitting another PRESTART job with QUSER

QSQSRVR QUSER 267369 PJ ACTIVE

This prestart job's library list is taken from Prestart JobD (QDFTSVR/QGPL ) which I can't change because the same prestart job might be using for different purpose. Is there a way to configure to use a particular prestart job instead of using QSQSRVR always.?

deepakpenjarla avatar Jan 23 '20 02:01 deepakpenjarla

One more question here,, If we do not specify library Name in iPGM options, from which library list it tries to find the program.? Is it from current library list.?

deepakpenjarla avatar Jan 24 '20 05:01 deepakpenjarla

@deepakpenjarla

One more question here,, If we do not specify library Name in iPGM options, from which library list it tries to find the program.? Is it from current library list.?

Yes it should try to use your library list first.

Below is an example changing your library list using v0.1.6:

const { iConn, iCmd, xmlToJson } = require('itoolkit');

const conn = new iConn('*LOCAL', process.env.USER, process.env.PASSWORD);

conn.add(iCmd("RTVJOBA USRLIBL(?) SYSLIBL(?)"));
conn.add(iCmd("CHGLIBL LIBL(QXMLSERV)"));
conn.add(iCmd("RTVJOBA USRLIBL(?) SYSLIBL(?)"));

conn.run((xmlOut) => {
  const output = xmlToJson(xmlOut);
  for (let command of output) {
   console.log(command);
  }
});

Output:

{
  type: 'cmd',
  success: true,
  cmd: 'RTVJOBA USRLIBL(?) SYSLIBL(?)',
  data: [
    {
      name: 'USRLIBL',
      value: 'QGPL       QTEMP      QDEVELOP   QBLDSYS    QBLDSYSR'
    },
    {
      name: 'SYSLIBL',
      value: 'QSYS       QSYS2      QHLPSYS    QUSRSYS'
    }
  ]
}
{ type: 'cmd', success: true, cmd: 'CHGLIBL LIBL(QXMLSERV)' }
{
  type: 'cmd',
  success: true,
  cmd: 'RTVJOBA USRLIBL(?) SYSLIBL(?)',
  data: [
    { name: 'USRLIBL', value: 'QXMLSERV' },
    {
      name: 'SYSLIBL',
      value: 'QSYS       QSYS2      QHLPSYS    QUSRSYS'
    }
  ]
}

abmusse avatar Jan 24 '20 23:01 abmusse

@abmusse Thanks for your answer. Yes, I agree we can use Retrieve and Change but if partiular JOBD is having 15-20 libraries then I need to retrieve and set the library list before every call of program. And, if I use the calling of a program in a POST request then I might be doing the same for every POST request. Is there a way to set the Node to always refer to a particular JOBD libraries.? may be in the current versions of itoolkit (I might be using older version).?

deepakpenjarla avatar Jan 25 '20 14:01 deepakpenjarla

Why do you need to retrieve it? Just set it exactly how you want it.

kadler avatar Jan 27 '20 14:01 kadler

@kadler I would like to use Library list from a JOBD, so to get the library list, I need to retrieve the library list from a particular JOBD and set it.

deepakpenjarla avatar Jan 30 '20 04:01 deepakpenjarla

Ok, gotcha.

kadler avatar Jan 30 '20 16:01 kadler

You may also be able to specify the ctl transport option like so: *sbmjob(LIBNAME/JOBD/JOBNAME)

I believe this will result in the XMLService jobs being submitted to batch under the given *JOBD. https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Toolkit%20for%20i%20APIs

Of course, there will be more overhead associated with submitting those batch jobs, but you can mitigate some of that with prestarted jobs and/or using the ipc parameter. http://yips.idevcloud.com/wiki/index.php/XMLService/XMLSERVICEQuick

ThePrez avatar Jan 31 '20 21:01 ThePrez

Hi @ThePrez I tried to use the iConn option as below

var conn = new xt.iConn("*LOCAL","USER01","XXXXX",ctl:'*sbmjob(QGPL/NEWUIJOBD/NODE_JB)',ipc:'/tmp/pdeepak/'});

I see it is submitting a job with NODE_JB with specified JOBD (NEWUIJOBD) but still library list for the job is User's JOBD library list. Am I missing something here.? or is it because of XMLSERVICE version or itoolkit version we are using.?

deepakpenjarla avatar Feb 04 '20 05:02 deepakpenjarla

I found this old doc on library list in XMLSERVICE: http://yips.idevcloud.com/wiki/index.php/XMLService/XMLSERVICELibl

It generates the SBMJOB command like this: https://github.com/IBM/xmlservice/blob/491b0d3ccf246c278564b510f7c21dfa83f04837/src/plugipc.rpgle#L1410-L1445

There is a way to alter it, but it's a compile-time option: https://github.com/IBM/xmlservice/blob/9b9fa7dfe90a8490cfa984bf6676984d569311c3/src/plugconf_h.rpgle#L139-L148 and its hard-coded to use the current job's library list.

kadler avatar Feb 04 '20 15:02 kadler

This sounds like a reasonable enhancement request to be routed to XMLService team for consideration.

According to this comment: https://github.com/IBM/xmlservice/blob/9b9fa7dfe90a8490cfa984bf6676984d569311c3/src/plugconf_h.rpgle#L137 Version 1.7.3 predates git control, so tracing history with certainty is impossible. However, I strongly suspect the "Alan" is @alanseiden. I will reach out to him to see if he remembers the reasoning behind that change (besides some obvious ones).

ThePrez avatar Feb 04 '20 16:02 ThePrez

@ThePrez With the PHP toolkit, most users did not hand-craft a *SBMJOB string. To do so was rare, perhaps not even possible at first, and definitely more obscure than with the Node toolkit instantiation code I see discussed here. Users typically accepted the defaults (the Zend JOBD) and expected their user profile's library list to hold sway. They complained when their user profile's library list seemed to have no effect.

alanseiden avatar Feb 06 '20 23:02 alanseiden

@alanseiden I understand, usually we do not do *SBMJOB with a JOBD name but I believe setting up library list from User JOBD should happen when we do not use *SBMJOB (default way). If we specify a particular JOBD, it should use that JOBDs library list.

deepakpenjarla avatar Feb 12 '20 12:02 deepakpenjarla

Listed some examples below.. if none is the case, can I get detailed explanation on the usage to get clear about what xmlservice expected to do?

  • ipc mode
  1. Use setting from *sbmjob() call program(by default it's XMLSERVICE pgm) with IPC key.. SBMJOB is only called when IPC "server" is not up. If this is the case, plugconf_h is designed to be customized by user in compile phase. I don't think the default values should be changed for minorities.
call qxmlserv.iPlug32k('/tmp/mykey',
'*sbmjob(JIMO/XSTESTJOBD/XSTEST)',
'<?xml version=''1.0''?>',
'?');
  1. Use from user input. Your SBMJOB will be called. describe your libl in the command
call qxmlserv.iPlug32k('/tmp/mykey',
'*sbmjob',
'<?xml version=''1.0''?>
  <sbmjob>SBMJOB CMD(CHGDTAARA DTAARA(JIMO/ADTAARA *ALL) VALUE(''2'')) JOB(XSSBMJOB) JOBD(JIMO/XSSBMJOBD) INLLIBL(*JOBD)</sbmjob>
',
'?');
  • stateless mode:

Just a command to write as you wish.. describe your libl in the command

call qxmlserv.iPlug32k('*NA',
'*here',
'<?xml version=''1.0''?>
    <cmd>SBMJOB CMD(CHGDTAARA DTAARA(JIMO/ADTAARA *ALL) VALUE(''2'')) JOB(XSSBMJOB) JOBD(JIMO/XSSBMJOBD) INLLIBL(*JOBD)</cmd>
',
'?');

jimoibm avatar Dec 08 '20 04:12 jimoibm

FWIW I always control my library list with the ODBC connection string DBQ parameter and don't try to have a JOBD manage it. It appears that the *SBMJOB inherits it in my quick and dirty testing.

brandonp42 avatar Nov 10 '22 20:11 brandonp42