Error calling program. Code: UNEXPECTED Msg: XML run loop fa

ffleer
Posts: 17
Joined: Tue Jan 31, 2012 10:44 am

Re: Error calling program. Code: UNEXPECTED Msg: XML run loo

Post by ffleer » Wed May 22, 2013 10:27 am

Thanks for your (honest) feedback.

I think this is a pretty serious shortcoming. We simply can not re-use existing (service) programs that rely on %parms().
In our company every program change must go thru a change management system, it would take ages to change existing programs.

Nevertheless I like the XML toolkit a lot. Well done.

rangercairns
Posts: 222
Joined: Fri Jul 24, 2009 6:28 pm

Re: Error calling program. Code: UNEXPECTED Msg: XML run loo

Post by rangercairns » Fri May 24, 2013 7:45 pm

Well ... perhaps yes ... except ... i don't really consider writing more RPG/SRVPGM programs to be unacceptable (funny world we live in today ... seems to run by project managers with Scrooge McDuck wallets)
1) no toolkit i know can handle %parms (PHP toolkit keeping up with Jones really)
Why? ILE does encapsulate concept of program descriptor, which is fancy term for you don't have access to APIs.
BTW -- hallmark of IBM security ... don't let anyone access anything (including php toolkit hacker/pirate).

2) workarounds over touching your current code via *SRVPGM wrapper -> *SRVPGM notouchme

Example 1:
MYWRAPPER (*srvpgm) with multiple calls to another MYNOTOUCH (*srvpgm) ...

Code: Select all

MYWRAPPER (*srvpgm)
     P parmMe1         B                   export
     D parmMe1         PI            50A   varying
     D  parm1                        10A
      /free
        // ok, called by PHP toolkit (any toolkit)
        return parmMe(parm1);
      /end-free
     P                 E

     P parmMe2         B                   export
     D parmMe2         PI            50A   varying
     D  parm1                        10A
     D  parm2                        10A
      /free
        // ok, called by PHP toolkit (any toolkit)
        return parmMe(parm1:parm2);
      /end-free
     P                 E

     P parmMe3         B                   export
     D parmMe3         PI            50A   varying
     D  parm1                        10A
     D  parm2                        10A
     D  parm3                        10A
      /free
        // ok, called by PHP toolkit (any toolkit)
        return parmMe(parm1:parm2:parm3);
      /end-free
     P                 E

     P parmMe4         B                   export
     D parmMe4         PI            50A   varying
     D  parm1                        10A
     D  parm2                        10A
     D  parm3                        10A
     D  parm4                        10A
      /free
        // ok, called by PHP toolkit (any toolkit)
        return parmMe(parm1:parm2:parm3:parm4);
      /end-free
     P                 E


MYNOTOUCH (*srvpgm) 
     D parmMe          PI            50A   varying
     D  parm1                        10A
     D  parm2                        10A   options(*nopass)
     D  parm3                        10A   options(*nopass)
     D  parm4                        10A   options(*nopass)
      /free
        // ok, called by MYWRAPPER (*srvpgm)
        if %parms ...
      /end-free
     P                 E



Example 2:
MYWRAPPER (*srvpgm) with *OMIT call to another MYNOTOUCH (*srvpgm) ... BUTAlan needs to add *OMIT to php toolkit (ok in xmlservice)

Code: Select all

MYWRAPPER (*srvpgm)
     D parmMeW         PI            50A   varying
     D  parm1                        10A
     D  parm2                        10A   options(*OMIT)
     D  parm3                        10A   options(*OMIT)
     D  parm4                        10A   options(*OMIT)
      * vars
     D argc            S             10i 0 inz(0)
     D fail            S             50A   inz(*BLANKS) varying
      /free
        // ok, called by PHP toolkit (any toolkit)
        // parm1
        argc = 1;
        if %addr(parm2) <> *NULL;
          argc += 1;
        endif;
        if %addr(parm3) <> *NULL;
          argc += 1;
        endif;
        if %addr(parm4) <> *NULL;
          argc += 1;
        endif;
        if %addr(parm1) <> *NULL;
          argc += 1;
        endif;
       select;
       when argc = 1;
        return parmMe(parm1);
       when argc = 2;
        return parmMe(parm1:parm2);
       when argc = 3;
        return parmMe(parm1:parm2:parm3);
       when argc = 4;
        return parmMe(parm1:parm2:parm3:parm4);
       // ???? 
       other;
       endsl;
       fail = "Uf Da I failed";
       return fail;
      /end-free
     P                 E


MYNOTOUCH (*srvpgm) 
     D parmMe          PI            50A   varying
     D  parm2                        10A   options(*nopass)
     D  parm3                        10A   options(*nopass)
     D  parm4                        10A   options(*nopass)
      /free
        // ok, called by MYWRAPPER (*srvpgm)
        if %parms ...
      /end-free
     P                 E


rangercairns
Posts: 222
Joined: Fri Jul 24, 2009 6:28 pm

Re: Error calling program. Code: UNEXPECTED Msg: XML run loo

Post by rangercairns » Fri May 24, 2013 8:15 pm

Oh for Pete sake (i need a long weekend)
... i forgot there is a way to do this with xmlservice ... there is a setting we put in for V5R4 (OPM mode) that will do the job right!!!
... i dunno if Alan needs to do something to toolkit, but isuspect you need a finer setting per program call over toolkit.ini (please, please Alan).

Code: Select all

<pgm mode='opm' 
Example output:

Code: Select all

> php zznopass.php

string(287) "<?xml version='1.0'?>
<script>
<pgm mode='opm' name='ZZSRV' lib='XMLSERVICE' func='ZZNOPASS'>
<parm comment='my name'>
<data var='myName' type='10A'>Roger</data>
</parm>
<return>
<data var='myReturnName' type='50A' varying='on'>my name is 1 Roger NOPASS</data>
</return>
</pgm>
</script>"
> 

Code: Select all

<?php
// see connection.inc param details ...
require_once('connection.inc');
// call IBM i
if ($i5persistentconnect) $conn = db2_pconnect($database,$user,$password);
else $conn = db2_connect($database,$user,$password);
if (!$conn) die("Bad connect: $database,$user");
$stmt = db2_prepare($conn, "call $procLib.iPLUG32K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml1();
$clobOut = "";
$ret=db2_bind_param($stmt, 1, "ipc", DB2_PARAM_IN);
$ret=db2_bind_param($stmt, 2, "ctl", DB2_PARAM_IN);
$ret=db2_bind_param($stmt, 3, "clobIn", DB2_PARAM_IN);
$ret=db2_bind_param($stmt, 4, "clobOut", DB2_PARAM_OUT);
$ret=db2_execute($stmt);
if (!$ret) die("Bad execute: ".db2_stmt_errormsg());
var_dump($clobOut);

//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zznopass: check nopass (does not work XML cnt = -1)
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zznopass        B                   export
//     D zznopass        PI            50A   varying
//     D  myName                       10A
//     D  yourName                     10A   options(*NOPASS)
function getxml1() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm mode='opm' name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZNOPASS'>
 <parm comment='my name'>
  <data var='myName' type='10A'>Roger</data>
 </parm>
 <return>
  <data var='myReturnName' type='50A' varying='on'>Mud</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>



SRVPGM:

Code: Select all


      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      * zznopass: check nopass (does not work XML cnt = -1)
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P zznopass        B                   export
     D zznopass        PI            50A   varying
     D  myName                       10A
     D  yourName                     10A   options(*NOPASS)
      * vars
     D tmp             S             50A   varying
     D cnt             S             10i 0 inz(0)
      /free
       cnt = %parms;
       tmp = 'my name is ' + %char(cnt) + ' ';
       if %parms > 1;
         tmp = tmp + %trim(myName) + ' ' + %trim(yourName);
       else;
         tmp = tmp + %trim(myName) + ' NOPASS';
       endif;
       return tmp;
      /end-free
     P                 E



aseiden
Posts: 875
Joined: Thu Apr 09, 2009 5:45 pm

Re: Error calling program. Code: UNEXPECTED Msg: XML run loo

Post by aseiden » Fri May 24, 2013 8:35 pm

The 'opm' mode can be specified dynamically in the PHP Toolkit.

It's called 'v5r4' because that was the situation we were addressing last year, but it's the same as 'opm' in XMLSERVICE.

Code: Select all

// turn on opm mode
$tkit->setOptions(array('v5r4'=>true));

// call program that needs opm mode
$tkit->PgmCall('PGMNAME', 'LIB', $params);

// turn off opm mode if don't need it anymore
$tkit->setOptions(array('v5r4'=>false));
--Alan

aseiden
Posts: 875
Joined: Thu Apr 09, 2009 5:45 pm

Re: Error calling program. Code: UNEXPECTED Msg: XML run loo

Post by aseiden » Fri May 24, 2013 8:42 pm

In Frank's case, because he uses a subprocedure, I should have included a fifth parameter on the PgmCall method: array('func'=>'WACHT').

--Alan

rangercairns
Posts: 222
Joined: Fri Jul 24, 2009 6:28 pm

Re: Error calling program. Code: UNEXPECTED Msg: XML run loo

Post by rangercairns » Fri May 24, 2013 8:55 pm

Thanks Alan ... just the cat's meow ... it works ...

Output:

Code: Select all

> php zznopasstoolkit.php

array(2) {
  ["io_param"]=>
  NULL
  ["retvals"]=>
  array(1) {
    ["myResult"]=>
    string(25) "my name is 1 ROGER NOPASS"
  }
}
> 

Toolkit sample ...

Code: Select all

<?php
require_once('connection.inc');
require_once("ToolkitService.php");

try { $ToolkitServiceObj = ToolkitService::getInstance($database, $user, $password); }
catch (Exception $e) { die($e->getMessage()); }
$ToolkitServiceObj->setToolkitServiceParams(array('plug'=>"iPLUG32K"));
$param   = array();
$param[] = $ToolkitServiceObj->AddParameterChar('in',  10,  'myName', 'myName', 'ROGER');
$result  = array();
$result[] = $ToolkitServiceObj->AddParameterChar('out',  50,  'myResult', 'myResult', 'MUD', 'on');
$ToolkitServiceObj->setOptions(array('v5r4'=>true));
$answer  = $ToolkitServiceObj->PgmCall('ZZSRV', 'XMLSERVICE', $param, $result, array('func'=>'ZZNOPASS'));
$ToolkitServiceObj->setOptions(array('v5r4'=>false));
var_dump($answer);
?>


RPG program with %parms ...

Code: Select all

     P zznopass        B                   export
     D zznopass        PI            50A   varying
     D  myName                       10A
     D  yourName                     10A   options(*NOPASS)
      * vars
     D tmp             S             50A   varying
     D cnt             S             10i 0 inz(0)
      /free
       cnt = %parms;
       tmp = 'my name is ' + %char(cnt) + ' ';
       if %parms > 1;
         tmp = tmp + %trim(myName) + ' ' + %trim(yourName);
       else;
         tmp = tmp + %trim(myName) + ' NOPASS';
       endif;
       return tmp;
      /end-free
     P                 E



ffleer
Posts: 17
Joined: Tue Jan 31, 2012 10:44 am

Re: Error calling program. Code: UNEXPECTED Msg: XML run loo

Post by ffleer » Tue May 28, 2013 10:48 am

Yes this 'v5r4' trick works indeed !!! Great job.

rangercairns, you deserve your long weekend.

Thanks very much for your support guys. Much appreciated.

eaburk
Posts: 82
Joined: Mon Jan 04, 2010 3:42 pm

Re: Error calling program. Code: UNEXPECTED Msg: XML run loo

Post by eaburk » Wed Dec 04, 2013 7:54 pm

I have installed ZendServer 6.2 and with the default version of the toolkit that comes with this installation i am seeing the %parms issue. I've tried returning the value of the %parms variable and the XML parameters always comes back as a "-" character. The v5r4 "trick" didn't work.

aseiden
Posts: 875
Joined: Thu Apr 09, 2009 5:45 pm

Re: Error calling program. Code: UNEXPECTED Msg: XML run loo

Post by aseiden » Thu Dec 05, 2013 1:30 am

Dear eaburk,

Does your use of %parms resemble that of Ranger's sample RPG program, posted "Fri May 24, 2013 3:55 pm?" If not, how is it different? If so, could you try Ranger's sample with the PHP sample posted and tell us if that works?

Thanks,
Alan

eaburk
Posts: 82
Joined: Mon Jan 04, 2010 3:42 pm

Re: Error calling program. Code: UNEXPECTED Msg: XML run loo

Post by eaburk » Thu Dec 05, 2013 4:18 pm

RPG Code:

Code: Select all

P @PastCutoff     B                   Export                
D                 PI             1                          
D Store                          5  0 Const                 
D ReqDate                         D   Const                 
D cutoffTime                      t   Const options(*nopass)
d cnt             s              1a                         
 /free
     cnt = %char(%parms);
     return cnt;         
 /end-free
P @PastCutoff     E
PHP Code:

Code: Select all

	$cust=12345;
	$rqdt='2013-12-05';
   $retval='';
	
	$param[] = $ToolkitService->AddParameterPackDec('in', 5, 0,'CUST', 'CUST', $cust);
	$param[] = $ToolkitService->AddParameterChar('in', 10,'RQDT', 'RQDT', $rqdt);
	$return[] = $ToolkitService->AddParameterChar('both', 1,'RETVAL', 'RETVAL', $retval);
	$result = $ToolkitService->PgmCall('SRVPGM', '*LIBL', $param, $return, array('func'=>'@PASTCUTOFF'));
	print_r($result);
Output:

Code: Select all

Array ( [io_param] => Array ( ) [retvals] => Array ( [RETVAL] => - ) )

Post Reply