From YiPs Wiki (i powered)

XMLSERVICE: XMLSERVICE Examples

(click to open)

Quick Page Table of Contents

Scanning…

XMLSERVICE RAW XML Examples

Goto Main Page
Goto Documents

This is not the Zend PHP Toolkit interface, instead this is what happens below that “nice” PHP interface wrapper.

PGM simple step

<?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");
for ($i=0; $i<5; $i++) {
  $stmt = db2_prepare($conn, "call $libxmlservice.iPLUG4K(?,?,?,?)");
  if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
  $clobIn = getxml();
  $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());
  // -----------------
  // output processing
  // -----------------
  // dump raw XML (easy test debug)
  var_dump($clobOut);
  // xml check via simplexml vs. expected results
  $xmlobj = simplexml_load_string($clobOut);
  if (!$xmlobj) die("Bad XML returned");
  $allpgms = $xmlobj->xpath('/script/pgm');
  if (!$allpgms) die("Missing XML pgm info");
  $pgm = $allpgms[0];
  $name = $pgm->attributes()->name;
  $lib  = $pgm->attributes()->lib;
  $func = $pgm->attributes()->func;
  // pgm return
  $retn = $pgm->xpath('return');
  if (!$retn) die("No XML pgm return ($lib/$name.$func)");
  $data = (string)$retn[0]->data;
  if ($data == 0) die("return not greater than '0'");
  // good
  echo "Success ($lib/$name.$func return $data)\n";
}

function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZSTEP'>
 <return>
  <data type='10i0'>0</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

PGM complex parameters plus DS

<?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 $libxmlservice.iPLUG4K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Missing XML pgm parms ($lib/$name)");
if ((string)$parm[0]->data != 'C') die("1) INCHARA not 'C'");
if ((string)$parm[1]->data != 'D') die("2) INCHARB not 'D'");
if ((string)$parm[2]->data != '321.1234') die("3) INDEC1  not '321.1234'");
if ((string)$parm[3]->data != '1234567890.12') die("4) INDEC2  not '1234567890.12'");
// parm 5 data structure
$ds = $parm[4]->ds;
if ((string)$ds->data[0] != 'E') die("5) INDS1.DSCHARA not 'E'");
if ((string)$ds->data[1] != 'F') die("5) INDS1.DSCHARB not 'F'");
if ((string)$ds->data[2] != '333.3330') die("5) INDS1.DSDEC1  not '333.3330'");
if ((string)$ds->data[3] != '4444444444.44') die("5) INDS1.DSDEC2  not '4444444444.44'");
// pgm return
$retn = $pgm->xpath('return');
if (!$retn) die("No XML pgm return ($lib/$name)");
if ((string)$retn[0]->data != '0') die("return not '0'");

// good
echo "Success ($lib/$name)\n";

//     D  INCHARA        S              1a
//     D  INCHARB        S              1a
//     D  INDEC1         S              7p 4        
//     D  INDEC2         S             12p 2
//     D  INDS1          DS                  
//     D   DSCHARA                      1a
//     D   DSCHARB                      1a           
//     D   DSDEC1                       7p 4      
//     D   DSDEC2                      12p 2            
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * main(): Control flow
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     C     *Entry        PLIST                   
//     C                   PARM                    INCHARA
//     C                   PARM                    INCHARB
//     C                   PARM                    INDEC1
//     C                   PARM                    INDEC2
//     C                   PARM                    INDS1
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZCALL' lib='xyzlibxmlservicexyz'>
 <parm  io='both'>
   <data type='1A' var='INCHARA'>a</data>
 </parm>
 <parm  io='both'>
   <data type='1A' var='INCHARB'>b</data>
 </parm>
 <parm  io='both'>
   <data type='7p4' var='INDEC1'>11.1111</data>
 </parm>
 <parm  io='both'>
   <data type='12p2' var='INDEC2'>222.22</data>
 </parm>
 <parm  io='both'>
  <ds>
   <data type='1A' var='INDS1.DSCHARA'>x</data>
   <data type='1A' var='INDS1.DSCHARB'>y</data>
   <data type='7p4' var='INDS1.DSDEC1'>66.6666</data>
   <data type='12p2' var='INDS1.DSDEC2'>77777.77</data>
  </ds>
 </parm>
 <return>
  <data type='10i0'>0</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

SRVPGM return complex array DS

<?php
// -----------------
// make the call
// -----------------
// 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("Fail connect: $database,$user");
$stmt = db2_prepare($conn, "call $libxmlservice.iPLUG65K(?,?,?,?)");
if (!$stmt) die("Fail prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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("Fail execute: ".db2_stmt_errormsg());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Fail XML returned\n");
// -----------------
// output cmd call
// -----------------
$allcmds = $xmlobj->xpath('/script/cmd');
if (!$allcmds) die("Fail XML cmd missing\n");
// -----------------
// output pgm call
// -----------------
$myName1 = 'Ranger';  // expected name
$myMax1  = 5;         // expected max
$myCount1= 5;         // expected count
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Fail XML pgm missing\n");
$pgm  = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
$func = $pgm->attributes()->func;
// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Fail XML pgm parms missing ($lib/$name.$func)\n");
$myName = (string)$parm[0]->data;
$myMax  = (string)$parm[1]->data;
$myCount= (string)$parm[2]->data;
if ($myName != $myName1) die("Fail myName ($myName not $myName1) ($lib/$name.$func)\n");
if ($myMax != $myMax1) die("Fail (myMax $myMax not $myMax1) ($lib/$name.$func)\n");
if ($myCount != $myCount1) die("Fail myCount ($myCount not $myCount1) ($lib/$name.$func)\n");
// pgm data structure returned dim(999)
$retn = $pgm->xpath('return');
if (!$retn) die("Fail XML pgm return missing ($lib/$name.$func)\n");
$dsret = $retn[0]->ds; // DS records returned
if (count($dsret) != $myCount) {
  die("Fail XML pgm not return $myCount DS records ($lib/$name.$func)\n");
}
$AAAs = "";
for ($j=0;$j<4095;$j++) $AAAs .= "A";
$i=0; // DS records
foreach($dsret as $ds) {
  // DS records expected
  $irpg     = $i+1;
  $dcMyName = $myName1.$irpg;
  if ($myMax > 10) $dcMyJob = $AAAs;
  else             $dcMyJob = "Test 10".$irpg;
  $dcMyRank = 10+$irpg;
  $dcMyPay  = sprintf("%1.2f", 13.42*$irpg);
  $data1 = array($dcMyName,$dcMyJob,$dcMyRank,$dcMyPay);
  // DS data elements
  for ($j=0;$j<4;$j++) {
    $var    = $ds->data[$j]->attributes()->var;
    $actual = (string)$ds->data[$j];
    $expect = $data1[$j];
    if ((string)$actual != $expect) {
      die("Fail dcRec_t[$i].$var ($actual != $expect) ($lib/$name.$func)\n");
    }
  }
  $i++;
}

// good
echo "Success ($lib/$name.$func)\n";

//     D ARRAYMAX        c                   const(999)
//     D dcRec_t         ds                  qualified based(Template)
//     D  dcMyName                     10A
//     D  dcMyJob                    4096A
//     D  dcMyRank                     10i 0
//     D  dcMyPay                      12p 2
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zzarray: check return array aggregate 
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zzarray         B                   export
//     D zzarray         PI                  likeds(dcRec_t) dim(ARRAYMAX)
//     D  myName                       10A
//     D  myMax                        10i 0
//     D  myCount                      10i 0
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<cmd comment='addlible'>ADDLIBLE LIB(xyzlibxmlservicexyz) POSITION(*FIRST)</cmd>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZARRAY'>
 <parm comment='search this name'>
  <data var='myName' type='10A'>Ranger</data>
 </parm>
 <parm comment='max allowed return'>
  <data var='myMax' type='10i0'>5</data>
 </parm>
 <parm comment='actual count returned'>
  <data var='myCount' type='10i0' enddo='mycount'>0</data>
 </parm>
 <return>
  <ds var='dcRec_t' dim='999' dou='mycount'>
    <data var='dcMyName' type='10A'>na</data>
    <data var='dcMyJob' type='4096A'>na</data>
    <data var='dcMyRank' type='10i0'>0</data>
    <data var='dcMyPay' type='12p2'>0.0</data>
  </ds>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

PGM very large OCCURS data

<?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 $libxmlservice.iPLUG10M(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
// var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");

// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;

// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Fail XML pgm parms missing ($lib/$name)\n");
// expected
$vevsfi = 'A';
$vevsrj = 'BB';
$vevsob = 22.0;
$vevsve = 33.0;
// $vevsods ds occurs(200)
$vsukz  = '1';
$vpos   = '23456789';
$vtxt   = 'lots o stuff';
$vkalw  = 42.42;
$vvsw   = 43.43;
$vvsk   = 2.0;
// top parms
$vevsfi1 = (string)$parm[0]->data;
$vevsrj1 = (string)$parm[1]->data;
$vevsob1 = (string)$parm[2]->data;
$vevsve1 = (string)$parm[3]->data;
if ($vevsfi != $vevsfi1) die("Fail vevsfi ($vevsfi not $vevsfi1) ($lib/$name)\n");
if ($vevsrj != $vevsrj1) die("Fail vevsrj ($vevsrj not $vevsrj1) ($lib/$name)\n");
if ($vevsob != $vevsob1) die("Fail vevsob ($vevsob not $vevsob1) ($lib/$name)\n");
if ($vevsve != $vevsve1) die("Fail vevsve ($vevsve not $vevsve1) ($lib/$name)\n");
// occurs DS
$dsall = $parm[4]->ds;
if (count($dsall) != 200) {
  die("Fail XML pgm not return 200 DS records ($lib/$name)\n");
}
// expect ds1
$ds1=array($vsukz,$vpos,$vtxt);
for ($j=0;$j<15;$j++) $ds1[]=$vkalw; 
for ($j=0;$j<15;$j++) $ds1[]=$vvsw; 
for ($j=0;$j<15;$j++) $ds1[]=$vvsk; 
// actual ds2
$i=1;
foreach ($dsall as $ds) {
  $vsukz1  = (string)$ds->data[0];
  $vpos1   = (string)$ds->data[1];
  $vtxt1   = (string)$ds->data[2];
  $ds2     = array($vsukz1,$vpos1,$vtxt1);
  for ($j=0;$j<15;$j++) {
    $vkalw1  = (string)$ds->data[$j+3];
    $ds2[]   = $vkalw1;
  }
  for ($j=0;$j<15;$j++) {
    $vvsw1   = (string)$ds->data[$j+18];
    $ds2[]   = $vvsw1;
  }
  for ($j=0;$j<15;$j++) {
    $vvsk1   = (string)$ds->data[$j+33];
    $ds2[]   = $vvsk1;
  }
  // any differences?
  $r = array_diff($ds1,$ds2);
  if ($r && count($r)) {
    echo substr($clobOut,0,3000)." ... \n";
    var_dump($r);
    die("Fail XML occurs($i) ($lib/$name)\n");
  }
  $i++;
}

// pgm data returned
$retn = $pgm->xpath('return');
if (!$retn) die("Fail XML pgm return missing ($lib/$name)\n");
$var  = $retn[0]->data->attributes()->var;
$actual = (string)$retn[0]->data;
$expect='0';
if ($actual != $expect) die("return: $var ($actual not $expect) ($lib/$name)\n");

// good
echo substr($clobOut,0,3000)." ... \n";
echo "Success ($lib/$name)\n";


//     D $vevsfi         s              1
//     D $vevsrj         s              2
//     D $vevsob         s              7s 0
//     D $vevsve         s              5s 0
//     D*Ergebnisdaten:
//     D $vevsods        ds                  occurs(200)
//     D $vsukz                  1      1
//     D $vpos                   2      9
//     D $vtxt                  10     39
//     D $vkalw                 40    174  2 dim(15)
//     D $vvsw                 175    309  2 dim(15)
//     D $vvsk                 310    324  0 dim(15)
//     d*
//     D i               S             10i 0 inz(0)
//     D j               S             10i 0 inz(0)
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * main(): Control flow
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     C     *Entry        PLIST
//     c                   parm                    $vevsfi
//     c                   parm                    $vevsrj
//     c                   parm                    $vevsob
//     c                   parm                    $vevsve
//     c                   parm                    $vevsods
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZERICH' lib='xyzlibxmlservicexyz'>
 <parm  io='both'>
   <data var='vevsfi' type='1A'>a</data>
 </parm>
 <parm  io='both'>
   <data var='vevsrj' type='2A'>bb</data>
 </parm>
 <parm  io='both'>
   <data var='vevsob' type='7s0'>11</data>
 </parm>
 <parm  io='both'>
   <data var='vevsve' type='5s0'>22.0</data>
 </parm>
 <parm  io='both'>
  <ds var='vevsods' dim='200'>
   <data var='vsukz' type='1A'>x</data>
   <data var='vpos' type='8A'>y</data>
   <data var='vtxt' type='30A'>hallo</data>
   <data var='vkalw' type='9s2' dim='15'>9.2</data>
   <data var='vvsw' type='9s2' dim='15'>8.2</data>
   <data var='vvsk' type='1s0' dim='15'>1.0</data>
  </ds>
 </parm>
 <return>
  <data var='ret' type='10i0'>0</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

SRVPGM very large data parameters

<?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 $libxmlservice.iPLUG512K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
// var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
$func = $pgm->attributes()->func;
// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Missing XML pgm parms ($lib/$name.$func)\n");
for ($i=1;$i<10;$i++) {
  $var  = $parm[$i-1]->data->attributes()->var;
  $data = (string)$parm[$i-1]->data;
  if ($data[0] != $i) die("$i) $var {$data[0]} not %i ($lib/$name.$func)\n");
  echo "$i) myNam$i {$data[0]} ok ($lib/$name.$func)\n";
}

// good
echo "Success ($lib/$name.$func)\n";

//     D zzbig           PR            10I 0
//     D  myNam1                    32000A
//     D  myNam2                    32000A
//     D  myNam3                    32000A
//     D  myNam4                    32000A
//     D  myNam5                    32000A
//     D  myNam6                    32000A
//     D  myNam7                    32000A
//     D  myNam8                    32000A
//     D  myNam9                    32000A
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zzbig: check big 
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zzbig           B                   export
//     D zzbig           PI            10I 0
//     D  myNam1                    32000A
//     D  myNam2                    32000A
//     D  myNam3                    32000A
//     D  myNam4                    32000A
//     D  myNam5                    32000A
//     D  myNam6                    32000A
//     D  myNam7                    32000A
//     D  myNam8                    32000A
//     D  myNam9                    32000A
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZBIG'>
 <parm>
  <data var='myNam1' type='32000A'>Ranger1</data>
 </parm>
 <parm>
  <data var='myNam2' type='32000A'>Ranger2</data>
 </parm>
 <parm>
  <data var='myNam3' type='32000A'>Ranger3</data>
 </parm>
 <parm>
  <data var='myNam4' type='32000A'>Ranger4</data>
 </parm>
 <parm>
  <data var='myNam5' type='32000A'>Ranger5</data>
 </parm>
 <parm>
  <data var='myNam6' type='32000A'>Ranger6</data>
 </parm>
 <parm>
  <data var='myNam7' type='32000A'>Ranger7</data>
 </parm>
 <parm>
  <data var='myNam8' type='32000A'>Ranger8</data>
 </parm>
 <parm>
  <data var='myNam9' type='32000A'>Ranger9</data>
 </parm>
 <return>
  <data type='10i0'>99</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

System data queues

<?php
// -----------------
// make the call
// -----------------
// 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("Fail connect: $database,$user");
$stmt = db2_prepare($conn, "call $libxmlservice.iPLUG65K(?,?,?,?)");
if (!$stmt) die("Fail prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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("Fail execute: ".db2_stmt_errormsg());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Fail XML returned\n");
// -----------------
// output cmd call
// -----------------
$allcmds = $xmlobj->xpath('/script/cmd');
if (!$allcmds) die("Fail XML cmd missing\n");
if (count($allcmds) != 3) die("Fail XML not return 3 CMD records\n");
// -----------------
// output pgm call
// -----------------
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Fail XML pgm missing\n");
if (count($allpgms) != 2) die("Fail XML not return 2 PGM records\n");
$expect = "System i data queues forever";
if (strpos($clobOut,$expect)<1) die("XML data missing ($expect)");

// good
echo "Success (data queue script)\n";


// work data queues
// CMD: dltdtaq,crtdtaq
// PGM: Send Data Queue (QSNDDTAQ) API
// 1 Data queue name     Input Char(10)
// 2 Library name        Input Char(10)
// 3 Length of data      Input Packed(5,0)
// 4 Data Input Char(*)  Input
// PGM: Receive Data Queue (QRCVDTAQ) API
// 1 Data queue name  Input Char(10)
// 2 Library name     Input Char(10)
// 3 Length of data   Input Packed(5,0)
// 4 Data Char(*)     Output
// 5 Wait time        Input Packed(5,0)
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<comment>
***************************************
* recreate the data queue
***************************************
</comment>
<cmd comment='dltdtaq MYDATAQ'>DLTDTAQ DTAQ(xyzlibxmlservicexyz/MYDATAQ)</cmd>
<cmd comment='crtdtaq MYDATAQ'>CRTDTAQ DTAQ(xyzlibxmlservicexyz/MYDATAQ) MAXLEN(100) AUT(*EXCLUDE)</cmd>
<comment>
***************************************
* Send Data Queue (QSNDDTAQ) API
***************************************
* 1 Data queue name     Input Char(10)
* 2 Library name        Input Char(10)
* 3 Length of data      Input Packed(5,0)
* 4 Data Input Char(*)  Input
</comment>
<pgm name='QSNDDTAQ'>
 <parm io='in'>
   <data type='10A'>MYDATAQ</data>
 </parm>
 <parm  io='in'>
   <data type='10A'>xyzlibxmlservicexyz</data>
 </parm>
 <parm  io='in'>
   <data type='5p0'>50</data>
 </parm>
 <parm  io='in'>
   <data type='100A'>System i data queues forever</data>
 </parm>
</pgm>
<comment>
***************************************
* Receive Data Queue (QRCVDTAQ) API
***************************************
* 1 Data queue name  Input Char(10)
* 2 Library name     Input Char(10)
* 3 Length of data   Input Packed(5,0)
* 4 Data Char(*)     Output
* 5 Wait time        Input Packed(5,0)
</comment>
<pgm name='QRCVDTAQ'>
 <parm  io='in'>
   <data type='10A'>MYDATAQ</data>
 </parm>
 <parm  io='in'>
   <data type='10A'>xyzlibxmlservicexyz</data>
 </parm>
 <parm  io='in'>
   <data type='5p0'>50</data>
 </parm>
 <parm io='out'>
   <data type='100A'>bad stuff here</data>
 </parm>
 <parm  comment='wait' io='in'>
   <data type='5p0'>0</data>
 </parm>
</pgm>
<cmd comment='dltdtaq MYDATAQ'>DLTDTAQ DTAQ(xyzlibxmlservicexyz/MYDATAQ)</cmd>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

System API QSZRTVPR

<?php
// -----------------
// make the call
// -----------------
// 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("Fail connect: $database,$user");
$stmt = db2_prepare($conn, "call $libxmlservice.iPLUG65K(?,?,?,?)");
if (!$stmt) die("Fail prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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("Fail execute: ".db2_stmt_errormsg());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
// var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Fail XML returned\n");
// -----------------
// output pgm call
// -----------------
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Fail XML pgm missing\n");
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Missing XML pgm parms ($name)");
// parm data structure Format PRDR0100
$ds = $parm[0]->ds;
$count = 0;
foreach($ds->data as $data) {
  echo $data->attributes()->comment.": ".(string)$data."\n";
  $count++;
}
if ($count <> 22) die("Fail XML Format PRDR0100");
// parm data structure Format ERRC0100
$ds = $parm[1]->ds;
$count = 0;
foreach($ds->data as $data) {
  echo $data->attributes()->comment.": ".(string)$data."\n";
  $count++;
}
if ($count <> 4) die("Fail XML Format ERRC0100");

// good
echo "Success ($name)\n";

/*
***************************************
* QSZRTVPR prod info
***************************************
* QSZRTVPR
* 1 Receiver variable            Output Char(*)
* 2 Length of receiver variable  Input  Binary(4)
* 3 Format name                  Input  Char(8)
* 4 Product information          Input  Char(*)
* 5 Error code                   I/O    Char(*)
*
* PRDR0100 Format
* 0   0   BINARY(4)  Bytes returned
* 4   4   BINARY(4)  Bytes available
* 8   8   BINARY(4)  Reserved
* 12  C   CHAR(7)    Product ID
* 19  13  CHAR(6)    Release level
* 25  19  CHAR(4)    Product option
* 29  1D  CHAR(4)    Load ID
* 33  21  CHAR(10)   Load type
* 43  2B  CHAR(10)   Symbolic load state
* 53  35  CHAR(10)   Load error indicator
* 63  3F  CHAR(2)    Load state
* 65  41  CHAR(1)    Supported flag
* 66  42  CHAR(2)    Registration type
* 68  44  CHAR(14)   Registration value
* 82  52  CHAR(2)    Reserved
* 84  54  BINARY(4)  Offset to additional information
* 88  58  CHAR(4)    Primary language load identifier
* 92  5C  CHAR(6)    Minimum target release
* 98  62  CHAR(6)    Minimum VRM of *BASE required
* 104 68  CHAR(1)    Requirements met between base
* 105 69  CHAR(3)    Level
* 108 6C  CHAR(*)    Reserved
*
* Format ERRC0100 for the error code
* 0 0 INPUT BINARY(4) Bytes provided
* 4 4 OUTPUT BINARY(4) Bytes available
* 8 8 OUTPUT CHAR(7) Exception ID
* 15 F OUTPUT CHAR(1) Reserved
*/
function getxml() {
$clob = <<<ENDPROC
<?xml version="1.0"?>
<script>
<pgm name='QSZRTVPR'>
 <parm io="out" comment='Receiver variable'>
  <ds comment='PRDR0100 Format'>
   <data type='10i0' comment='Bytes returned'>0</data>
   <data type='10i0' comment='Bytes available'>0</data>
   <data type='10i0' comment='Reserved'>0</data>
   <data type='7A' comment='Product ID'> </data>
   <data type='6A' comment='Release level'> </data>
   <data type='4A' comment='Product option'> </data>
   <data type='4A' comment='Load ID'> </data>
   <data type='10A' comment='Load type'> </data>
   <data type='10A' comment='Symbolic load state'> </data>
   <data type='10A' comment='Load error indicator'> </data>
   <data type='2A' comment='Load state'> </data>
   <data type='1A' comment='Supported flag'> </data>
   <data type='2A' comment='Registration type'> </data>
   <data type='14A' comment='Registration value'> </data>
   <data type='2A' comment='Reserved'> </data>
   <data type='10i0' comment='Offset to additional information'>0</data>
   <data type='4A' comment='Primary language load identifier'> </data>
   <data type='6A' comment='Minimum target release'> </data>
   <data type='6A' comment='Minimum VRM of *BASE required'> </data>
   <data type='1A' comment='Requirements met between base'> </data>
   <data type='3A' comment='Level'> </data>
   <data type='5A' comment='pad'> </data>
  </ds>
 </parm>
 <parm  io="in" comment='Length of receiver variable'>
   <data type='10i0'>108</data>
 </parm>
 <parm  io="in" comment='Format name'>
   <data type='8A'>PRDR0100</data>
 </parm>
 <parm  io="in" comment='Product information'>
   <data type='100A'>*OPSYS *CUR  0033*CODE</data>
 </parm>
 <parm  io="both" comment='Error code'>
  <ds comment='Format ERRC0100'>
   <data type='10i0' comment='Bytes returned'>0</data>
   <data type='10i0' comment='Bytes available'>16</data>
   <data type='7A' comment='Exception ID'> </data>
   <data type='1A' comment='Reserved'> </data>
  </ds>
 </parm>
</pgm>
</script>
ENDPROC;
return $clob;
}
?>

System API QWCRSSTS

<?php
// -----------------
// make the call
// -----------------
// 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("Fail connect: $database,$user");
$stmt = db2_prepare($conn, "call $libxmlservice.iPLUG65K(?,?,?,?)");
if (!$stmt) die("Fail prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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("Fail execute: ".db2_stmt_errormsg());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
// var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Fail XML returned\n");
// -----------------
// output pgm call
// -----------------
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Fail XML pgm missing\n");
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib = $pgm->attributes()->lib;
// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Missing XML pgm parms ($name)");
// parm data structure Format SSTS0100
$ds = $parm[0]->ds;
$count = 0;
foreach($ds->data as $data) {
  echo $data->attributes()->comment.": ".(string)$data."\n";
  $count++;
}
if ($count <> 18) die("Fail XML Format SSTS0100");
// parm data structure Format ERRC0100
$ds = $parm[1]->ds;
$count = 0;
foreach($ds->data as $data) {
  echo $data->attributes()->comment.": ".(string)$data."\n";
  $count++;
}
if ($count <> 5) die("Fail XML Format ERRC0100");

// good
echo "Success ($lib/$name)\n";

// QWCRSSTS
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0' encoding='ISO-8859-1'?>
<script>
<pgm name='QWCRSSTS' lib='QSYS'>
 <parm io='both'>
  <ds>
   <data type='10i0' var='BYTES' comment='BYTES'>0</data>
   <data type='10i0' var='RET' comment='RET'>1</data>
   <data type='8B' var='DATE_TIME' comment='DATE_TIME'>x</data>
   <data type='8A' var='SYSTEM' comment='SYSTEM'>x</data>
   <data type='10i0' var='USERS' comment='USERS'>0</data>
   <data type='10i0' var='DIS_USERS' comment='DIS_USERS'>0</data>
   <data type='10i0' var='SUSP_JOBS' comment='SUSP_JOBS'>0</data>
   <data type='10i0' var='JB_GP_SUSP' comment='JB_GP_SUSP'>0</data>
   <data type='10i0' var='USER_SIGNED_PRINT_WAIT' comment='USER_SIGNED_PRINT_WAIT'>0</data>
   <data type='10i0' var='MSG_WAIT' comment='MSG_WAIT'>0</data>
   <data type='10i0' var='BATCH_JOBS' comment='BATCH_JOBS'>0</data>
   <data type='10i0' var='HELD_BATCH' comment='HELD_BATCH'>0</data>
   <data type='10i0' var='END_BATCH' comment='END_BATCH'>0</data>
   <data type='10i0' var='WAITING_BATCH' comment='WAITING_BATCH'>0</data>
   <data type='10i0' var='BATCH_HELD_ON_QUE' comment='BATCH_HELD_ON_QUE'>0</data>
   <data type='10i0' var='BATCH_ON_HELD_QUE' comment='BATCH_ON_HELD_QUE'>0</data>
   <data type='10i0' var='UNASGN_BATCH' comment='UNASGN_BATCH'>0</data>
   <data type='10i0' var='BATCH_WAIT_PRINT' comment='BATCH_WAIT_PRINT'>0</data>
  </ds> 
 </parm>
 <parm comment='LEN' io='in'>
  <data type='10i0' var='LEN' >148</data>  		  
 </parm>
 <parm comment='FORMAT' io='in'> 			
  <data type='8A' var='FORMAT' >SSTS0100</data>  		  
 </parm>
 <parm comment='RESET' io='in'> 			
  <data type='10A' var='RESET' >*YES</data>  		  
 </parm>
 <parm io='both'>
  <ds>
   <data type='10i0' var='provided' comment='provided'>0</data>
   <data type='10i0' var='available' comment='available'>0</data>
   <data type='7A' var='Exception' comment='Exception'>x</data>
   <data type='1A' var='reserved' comment='reserved'>x</data>
   <data type='10A' var='data' comment='data'>x</data>
  </ds> 
 </parm>
</pgm>
</script>
ENDPROC;
return $clob;
}
?>

SRVPGM varying text

<?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 $libxmlservice.iPLUGR4K(?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$clobOut = "";
$ret=db2_execute($stmt,array($ipc,$ctl,$clobIn));
if (!$ret) die("Bad execute: ".db2_stmt_errormsg());
while ($row = db2_fetch_array($stmt)){
  $clobOut .= trim($row[0]);
}
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
$func = $pgm->attributes()->func;
// pgm parms
$parm = $pgm->xpath('parm');
if ($parm) die("Unexpected XML pgm parms io='in' ($lib/$name.$func)\n");
// pgm data returned
$retn = $pgm->xpath('return');
if (!$retn) die("Fail XML pgm return missing ($lib/$name.$func)\n");
$var  = $retn[0]->data->attributes()->var;
$actual = (string)$retn[0]->data;
$expect = 'my name is <Ranger>';
if ($actual != $expect) die("$var ($actual not $expect) ($lib/$name.$func)\n");

// good
echo "Success ($lib/$name.$func)\n";

//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zzvary: check return varying 
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zzvary          B                   export
//     D zzvary          PI            20A   varying
//     D  myName                       10A   varying
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0' encoding='ISO-8859-1' ?>
<script>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZVARY'>
 <parm comment='search this name' io='in'>
  <data var='myName' type='10A' varying='on'><![CDATA[<Ranger>]]></data>
 </parm>
 <return>
  <data var='myNameis' type='20A' varying='on'><![CDATA[<Mud>]]></data>
 </return>
</pgm>
</script>
ENDPROC;
$test = simplexml_load_string($clob);
return test_lib_replace($clob);
}
?>

SRVPGM varying text w/cdata XML

<?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 $libxmlservice.iPLUG32K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
$func = $pgm->attributes()->func;
// pgm parms
$parm = $pgm->xpath('parm');
if ($parm) die("Unexpected XML pgm parms io='in' ($lib/$name.$func)\n");
// pgm data returned
$retn = $pgm->xpath('return');
if (!$retn) die("Fail XML pgm return missing ($lib/$name.$func)\n");
$var  = $retn[0]->data->attributes()->var;
$actual = (string)$retn[0]->data;
$expect = 'my name is Ranger';
if ($actual != $expect) die("$var ($actual not $expect) ($lib/$name.$func)\n");

// good
echo "Success ($lib/$name.$func)\n";

//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zzvary: check return varying 
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zzvary          B                   export
//     D zzvary          PI            20A   varying
//     D  myName                       10A   varying
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZVARY'>
 <parm comment='search this name' io='in'>
  <data var='myName' type='10A' varying='on'>Ranger</data>
 </parm>
 <return>
  <data var='myReturnName' type='20A' varying='on'>Mud</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}

SRVPGM binary/hex data

<?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 $libxmlservice.iPLUG4K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
$func = $pgm->attributes()->func;
// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Fail XML pgm parms missing ($lib/$name.$func)\n");
$var  = $parm[0]->data->attributes()->var;
$actual = (string)$parm[0]->data;
$expect='A1A2A3A4A5A6A7A8A9AAA1A2A3A4A5A6A7A8A9AA';
if ($actual != $expect) die("parm: $var ($actual not $expect) ($lib/$name.$func)\n");
// pgm data returned
$retn = $pgm->xpath('return');
if (!$retn) die("Fail XML pgm return missing ($lib/$name.$func)\n");
$var  = $retn[0]->data->attributes()->var;
$actual = (string)$retn[0]->data;
$expect='A1A2A3A4A5A6A7A8A9AAA1A2A3A4A5A6A7A8A9AA';
if ($actual != $expect) die("return: $var ($actual not $expect) ($lib/$name.$func)\n");

// good
echo "Success ($lib/$name.$func)\n";

//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zzbinary: check return binary 
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zzbinary        B                   export
//     D zzbinary        PI            20A
//     D  myBinary                     20A
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZBINARY'>
 <parm comment='binary data'>
  <data var='myBinary' type='20B'>A1A2A3A4A5A6A7A8A9AAA1A2A3A4A5A6A7A8A9AA</data>
 </parm>
 <return>
  <data var='myBinRet' type='20B'>F1F2F3F4F5F6F7F8F9FAF1F2F3F4F5F6F7F8F9FA</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

SRVPGM date *iso

<?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 $libxmlservice.iPLUG4K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
$func = $pgm->attributes()->func;
// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Fail XML pgm parms missing ($lib/$name.$func)\n");
$var  = $parm[0]->data->attributes()->var;
$actual = (string)$parm[0]->data;
$expect='2007-09-30';
if ($actual != $expect) die("parm: $var ($actual not $expect) ($lib/$name.$func)\n");
// pgm data returned
$retn = $pgm->xpath('return');
if (!$retn) die("Fail XML pgm return missing ($lib/$name.$func)\n");
$var  = $retn[0]->data->attributes()->var;
$actual = (string)$retn[0]->data;
$expect='2009-05-11';
if ($actual != $expect) die("return: $var ($actual not $expect) ($lib/$name.$func)\n");

// good
echo "Success ($lib/$name.$func)\n";

//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zzdate: check date parm
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zzdate          B                   export
//     D zzdate          PI              D
//     D  myDate                         D   datfmt(*iso)
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZDATE'>
 <parm  io='both'>
   <data var='myDate' type='10A'>2009-05-11</data>
 </parm>
 <return>
   <data var='myDateRet' type='10A'>nada</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

SRVPGM date *USA

<?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 $libxmlservice.iPLUG4K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
$func = $pgm->attributes()->func;
// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Fail XML pgm parms missing ($lib/$name.$func)\n");
$var  = $parm[0]->data->attributes()->var;
$actual = (string)$parm[0]->data;
$expect='09/30/2007';
if ($actual != $expect) die("parm: $var ($actual not $expect) ($lib/$name.$func)\n");
// pgm data returned
$retn = $pgm->xpath('return');
if (!$retn) die("Fail XML pgm return missing ($lib/$name.$func)\n");
$var  = $retn[0]->data->attributes()->var;
$actual = (string)$retn[0]->data;
$expect='05/11/2009';
if ($actual != $expect) die("return: $var ($actual not $expect) ($lib/$name.$func)\n");

// good
echo "Success ($lib/$name.$func)\n";

//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zzdateUSA: check date parm
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zzdateUSA       B                   export
//     D zzdateUSA       PI              D   datfmt(*USA)
//     D  myDate                         D   datfmt(*USA)
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZDATEUSA'>
 <parm  io='both'>
   <data var='myDate' type='10A'>05/11/2009</data>
 </parm>
 <return>
   <data var='myDateRet' type='10A'>nada</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

SRVPGM time *iso

<?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 $libxmlservice.iPLUG4K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
$func = $pgm->attributes()->func;
// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Fail XML pgm parms missing ($lib/$name.$func)\n");
$var  = $parm[0]->data->attributes()->var;
$actual = (string)$parm[0]->data;
$expect='12.34.56';
if ($actual != $expect) die("parm: $var ($actual not $expect) ($lib/$name.$func)\n");
// pgm data returned
$retn = $pgm->xpath('return');
if (!$retn) die("Fail XML pgm return missing ($lib/$name.$func)\n");
$var  = $retn[0]->data->attributes()->var;
$actual = (string)$retn[0]->data;
$expect='09.45.29';
if ($actual != $expect) die("return: $var ($actual not $expect) ($lib/$name.$func)\n");

// good
echo "Success ($lib/$name.$func)\n";

//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zztime: check time parm
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zztime          B                   export
//     D zztime          PI              T
//     D  myTime                         T   timfmt(*iso)
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZTIME'>
 <parm  io='both'>
   <data var='myTime' type='8A'>09.45.29</data>
 </parm>
 <return>
   <data var='myTimeRet' type='8A'>nada</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

SRVPGM timestamp

<?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 $libxmlservice.iPLUG4K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
$func = $pgm->attributes()->func;
// pgm parms
$parm = $pgm->xpath('parm');
if (!$parm) die("Fail XML pgm parms missing ($lib/$name.$func)\n");
$var  = $parm[0]->data->attributes()->var;
$actual = (string)$parm[0]->data;
$expect='1960-12-31-12.32.23.000000';
if ($actual != $expect) die("parm: $var ($actual not $expect) ($lib/$name.$func)\n");
// pgm data returned
$retn = $pgm->xpath('return');
if (!$retn) die("Fail XML pgm return missing ($lib/$name.$func)\n");
$var  = $retn[0]->data->attributes()->var;
$actual = (string)$retn[0]->data;
$expect='2011-12-29-12.45.29.000000';
if ($actual != $expect) die("return: $var ($actual not $expect) ($lib/$name.$func)\n");

// good
echo "Success ($lib/$name.$func)\n";

//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zzstamp: check timestamp parm
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zzstamp         B                   export
//     D zzstamp         PI              Z
//     D  myStamp                        Z
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZSTAMP'>
 <parm  io='both'>
   <data var='myStamp' type='26A'>2011-12-29-12.45.29.000000</data>
 </parm>
 <return>
   <data var='myStampRet' type='26A'>nada</data>
 </return>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

Shell WRKACTJOB

<?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 $libxmlservice.iPLUG512K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
// -----------------
// output sh call
// -----------------
$sh = $xmlobj->xpath('/script/sh');
if (!$sh) die("Missing XML sh info");
$expect = 'E N D  O F  L I S T I N G'; // should be in the list
$missing = true;
foreach ($sh[0]->row as $row) {
  $data = (string)$row;
  if (strpos($data,$expect)>0) {
    $missing = false;
    break;
  } 
}
if ($missing) die("XML sh data missing ($expect)");

// good
echo "Success (PASE sh)\n";

// 5250:
// call qp2term
// /QOpenSys/usr/bin/system -i 'wrkactjob'
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<sh rows='on'>/QOpenSys/usr/bin/system -i 'wrkactjob'</sh>
</script>
ENDPROC;
return $clob;
}
?>

Shell PASE ls utility

<?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 $libxmlservice.iPLUG32K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
// -----------------
// output sh call
// -----------------
$sh = $xmlobj->xpath('/script/sh');
if (!$sh) die("Missing XML sh info");
$expect = 'pear'; // should be in the list
$missing = true;
foreach ($sh[0]->row as $row) {
  $data = (string)$row;
  if (strpos($data,$expect)>0) {
    $missing = false;
    break;
  } 
}
if ($missing) die("XML sh data missing ($expect)");

// good
echo "Success (PASE sh)\n";

// 5250:
// call qp2term
// /QOpenSys/usr/bin/ls /usr/local/zendsvr/bin
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<sh rows='on'>/QOpenSys/usr/bin/ls -l /usr/local/zendsvr/bin</sh>
</script>
ENDPROC;
return $clob;
}
?>

PGM setting fewer records input DS (1.2.1 beyond)

<?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 $libxmlservice.iPLUG512K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
// good
echo "Success ($lib/$name)\n";


//     d MyErrorDs       ds                  qualified based(Template)
//     d  ErrorId                       8a
//     d  Severity                      3u 0
//     d  Description                  80a
//     d ErrorParm       ds                  likeds(MyErrorDs) dim(20)
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * main(): Control flow
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     C     *Entry        PLIST                   
//     C                   PARM                    ErrorParm
//     C                   PARM                    NumOfErrors       2 0
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZVLAD2' lib='xyzlibxmlservicexyz'>
<parm io='both' comment='pointer arg 1'>
<ds var='MyErrorDs' comment='first data'>
<data type='8a' var='ErrorId'>12345678</data>
<data type='3u0' var='Severity'>1</data>
<data type='80a' var='Description'>Toad wrangler</data>
</ds>
<ds var='MyErrorDs' comment='right behind first'>
<data type='8a' var='ErrorId'>87654321</data>
<data type='3u0' var='Severity'>3</data>
<data type='80a' var='Description'>Frog wrangler</data>
</ds>
</parm>
<parm io='in' comment='pointer arg 2'>
<data type='2p0' var='NumOfErrors'>2.0</data>
</parm>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

PGM setting fewer records input DS overlay (1.2.1 beyond)

<?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 $libxmlservice.iPLUG512K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
// good
echo "Success ($lib/$name)\n";


//     d MyErrorDs       ds                  qualified based(Template)
//     d  ErrorId                       8a
//     d  Severity                      3u 0
//     d  Description                  80a
//     d ErrorParm       ds                  likeds(MyErrorDs) dim(20)
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * main(): Control flow
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     C     *Entry        PLIST                   
//     C                   PARM                    ErrorParm
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZVLAD3' lib='xyzlibxmlservicexyz'>
<parm io='in' dim='20' comment='init all'>
<ds var='MyErrorDs' comment='first data'>
<data type='8a' var='ErrorId'/>
<data type='3u0' var='Severity'/>
<data type='80a' var='Description'/>
</ds>
</parm>
<overlay io='both' top='on' comment='set any number messages'>
<ds var='MyErrorDs' comment='first data'>
<data type='8a' var='ErrorId'>12345678</data>
<data type='3u0' var='Severity'>1</data>
<data type='80a' var='Description'>Toad wrangler</data>
</ds>
<ds var='MyErrorDs' comment='right behind first'>
<data type='8a' var='ErrorId'>87654321</data>
<data type='3u0' var='Severity'>3</data>
<data type='80a' var='Description'>Frog wrangler</data>
</ds>
</overlay>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

SRVPGM customized output XML overlay (1.2.1 beyond)

<?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 $libxmlservice.iPLUG512K(?,?,?,?)");
if (!$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$clobIn = getxml();
$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());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
// var_dump($clobOut);
// xml check via simplexml vs. expected results
$xmlobj = simplexml_load_string($clobOut);
if (!$xmlobj) die("Bad XML returned");
$allpgms = $xmlobj->xpath('/script/pgm');
if (!$allpgms) die("Missing XML pgm info");
// -----------------
// output pgm call
// -----------------
// only one program this XML script
$pgm = $allpgms[0];
$name = $pgm->attributes()->name;
$lib  = $pgm->attributes()->lib;
$func = $pgm->attributes()->func;
// pgm parms
$parm = $pgm->xpath('overlay');
if (!$parm) die("Missing XML pgm parms ($lib/$name.$func)\n");
$cnt = count($parm);
if ($cnt <> 3) die("Missing 3 overlays (count = $cnt)\n");
for ($i=1;$i<=count($parm);$i++) {
  $top = "";
  if (isset($parm[$i-1]->attributes()->top)) {
    $top = "top=" . $parm[$i-1]->attributes()->top;
  }
  $cmt  = $parm[$i-1]->attributes()->comment;
  $off  = $parm[$i-1]->attributes()->offset;
  $var  = $parm[$i-1]->data->attributes()->var;
  $data = (string)$parm[$i-1]->data;
  echo "$i) $var offset=$off $top $cmt = $data ($lib/$name.$func)\n";
}

// good
echo "Success ($lib/$name.$func)\n";

//     D zzbig           PR            10I 0
//     D  myNam1                    32000A
//     D  myNam2                    32000A
//     D  myNam3                    32000A
//     D  myNam4                    32000A
//     D  myNam5                    32000A
//     D  myNam6                    32000A
//     D  myNam7                    32000A
//     D  myNam8                    32000A
//     D  myNam9                    32000A
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//      * zzbig: check big 
//      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     P zzbig           B                   export
//     D zzbig           PI            10I 0
//     D  myNam1                    32000A
//     D  myNam2                    32000A
//     D  myNam3                    32000A
//     D  myNam4                    32000A
//     D  myNam5                    32000A
//     D  myNam6                    32000A
//     D  myNam7                    32000A
//     D  myNam8                    32000A
//     D  myNam9                    32000A
function getxml() {
$clob = <<<ENDPROC
<?xml version='1.0'?>
<script>
<pgm name='ZZSRV' lib='xyzlibxmlservicexyz' func='ZZBIG'>
 <parm io='in'>
  <data var='myNam1' type='32000A'>Ranger1</data>
 </parm>
 <parm io='in'>
  <data var='myNam2' type='32000A'>Ranger2</data>
 </parm>
 <parm io='in'>
  <data var='myNam3' type='32000A'>Ranger3</data>
 </parm>
 <parm io='in'>
  <data var='myNam4' type='32000A'>Ranger4</data>
 </parm>
 <parm io='in'>
  <data var='myNam5' type='32000A'>Ranger5</data>
 </parm>
 <overlay io='out' offset='0' comment='prev parm'>
   <data var='myOver5' type='10A'>R5</data>
 </overlay>
 <parm io='in'>
  <data var='myNam6' type='32000A'>Ranger6</data>
 </parm>
 <parm io='in'>
  <data var='myNam7' type='32000A'>Ranger7</data>
 </parm>
 <parm io='in'>
  <data var='myNam8' type='32000A'>Ranger8</data>
 </parm>
 <parm io='in'>
  <data var='myNam9' type='32000A'>Ranger9</data>
 </parm>
 <overlay io='out' offset='0' top='on' comment='top parm'>
   <data var='myOver1' type='10A'>R1</data>
 </overlay>
 <overlay io='out' offset='192000' top='on' comment='middle parms'>
   <data var='myOverx' type='10A'>R1</data>
 </overlay>
</pgm>
</script>
ENDPROC;
return test_lib_replace($clob);
}
?>

Author(s)

Tony “Ranger” Cairns - IBM i PHP / PASE

Retrieved from http://youngiprofessionals.com/wiki/index.php/XMLSERVICE/XMLSERVICEExamples
Page last modified on October 21, 2013, at 02:11 PM EST