Hi, Ken,
Yes, with PHP toolkit version 1.4.0+ this task is easy to do.
If you don't already have this, you can install Zend's Toolkit update 12-12 from the Zend Server for IBM i download page.
Here's a sample script that should work for you. Just update the connection values, param values, and the pgmname and library.
- Code: Select all
<?php
require_once('ToolkitService.php');
// connection options (may vary)
$conn = ToolkitService::getInstance('*LOCAL', 'myuser', 'mypass');
// stateless mode is easiest connection type when getting started
$conn->setOptions(array('stateless'=>true));
// ensure data structure hierarchy, naming, etc.
$conn->setOptions(array('dataStructureIntegrity' => true));
// create PHP array containing data structure elements
$ds[] = $conn->addParameterChar('both', 10, 'comment for GENNMWP', 'GENNMWP', 'mycharabcd');
$ds[] = $conn->addParameterPackDec('both', 9, 0, 'comment for ACC#WP', 'ACC#WP', 123456789);
$ds[] = $conn->addParameterPackDec('both', 4, 0, 'comment for ONEWONWP', 'ONEWONWP', 1234);
$ds[] = $conn->addParameterPackDec('both', 3, 0, 'comment for ONEPRZ#WP', 'ONEPRZ#WP', 123);
$ds[] = $conn->addParameterPackDec('both', 2, 0, 'comment for ONEPCTWP', 'ONEPCTWP', 12);
$ds[] = $conn->addParameterPackDec('both', 4, 0, 'comment for TWOWONWP', 'TWOWONWP', 1234);
$ds[] = $conn->addParameterPackDec('both', 3, 0, 'comment for TWOPRZ#WP', 'TWOPRZ#WP', 123);
$ds[] = $conn->addParameterPackDec('both', 2, 0, 'comment for TWOPCTWP', 'TWOPCTWP', 12);
$ds[] = $conn->addParameterPackDec('both', 4, 0, 'comment for THRWONWP', 'THRWONWP', 1234);
$ds[] = $conn->addParameterPackDec('both', 3, 0, 'comment for THRPRZ#WP', 'THRPRZ#WP', 123);
// add data structure as a parameter
$params[] = $conn->addDataStruct($ds, 'myPackDs');
// call program with params. Receive array of output params back.
$result = $conn->PgmCall('MYPGM', 'MYLIB', $params);
if ($result) {
// output parameters after program call
echo '<PRE>' . print_r($result['io_param'], true) . '</PRE>';
} else {
echo 'Error calling program: ' . $conn->getErrorCode() . ' ' . $conn->getErrorMsg();
}
The output will resemble:
- Code: Select all
Array
(
[myPackDs] => Array
(
[GENNMWP] => mycharabcd
[ACC#WP] => 123456789
[ONEWONWP] => 1234
[ONEPRZ#WP] => 123
[ONEPCTWP] => 12
[TWOWONWP] => 1234
[TWOPRZ#WP] => 123
[TWOPCTWP] => 12
[THRWONWP] => 1234
[THRPRZ#WP] => 123
)
)
Ken, try and let us know if that does it.
--Alan Seiden