/** * Constructor takes an object name (program, data queue, user space) and array-based data description * and does some conversions. * * @param string $objName name of program, data queue, etc. lib/pgm(svcfunc) or the like. * @param array $dataDescription array of parameter definitions * @param Toolkit $connection connection object for toolkit * @internal param I5Error $errorObj during validation we may set properties of this object. */ public function __construct($objName, array $dataDescription, Toolkit $connection) { if (is_string($objName)) { $this->setOriginalObjName($objName); $objInfo = splitLibObj($objName); $this->setObjInfo($objInfo); } $this->_description = $dataDescription; $this->setConnection($connection); }
/** * Description: Create an spool file lists, of certain output queue or for all queues. * Return Values: resource if OK, false if failed * Arguments: * UNDOCUMENTED: jobnumber, jobname, too!!!!! but if specify jobname, must specify all three (name, number, user) * "*" for all three will give current job. * outq - qualified (optional library included) name for the output queue containing the spool file * userdata - the user-supplied key data for the spool file. * All keys are optional and can be provided together * * @param array $description The data by which the sppol files will be filtered, array with following keys: username - username that created the job * @param null $connection result of i5_connect * @return ListFromApi */ function i5_spool_list($description = array(), $connection = null) { if (!($connection = verifyConnection($connection))) { return false; } // check that criteria description is an array (OK if empty) if ($description && !is_array($description)) { i5ErrorActivity(I5_ERR_PHP_TYPEPARAM, I5_CAT_PHP, 'Criteria elements must be an array', 'Criteria elements must be an array'); return false; } $userData = ''; $outq = ''; $userName = ''; $jobUserName = ''; $jobName = ''; $jobNumber = ''; // use constants: //I5_USERDATA, I5_OUTQ, I5_USERNAME if (count($description)) { foreach ($description as $type => $value) { switch ($type) { case I5_USERDATA: $userData = $value; break; case I5_OUTQ: $outq = $value; break; case I5_USERNAME: $userName = $value; $jobUserName = $value; break; case I5_JOBNAME: $jobName = $value; break; case I5_JOBNUMBER: $jobNumber = $value; break; } } } // if jobname or jobnumber is provided then complete job info (all three params) must be provided. // otherwise give an I5_ERR_PHP_LIST_PROP error. // In other words, // (Not documented but shown in old toolkit unit tests.) $specifyJobParams = false; if (!empty($jobName) || !empty($jobNumber)) { // jobName or jobNumber is specified. Must have all three job params. if (empty($jobName) || empty($jobNumber) || empty($jobUserName)) { i5ErrorActivity(I5_ERR_PHP_LIST_PROP, I5_CAT_PHP, 'Incomplete job criteria specified.', 'If jobname or jobnumber are specified, then all three job criteria (jobname, jobnumber, and username) must be specified. You can use * to indicate current job.'); return false; } // if we didn't error out then we have all three job params. $specifyJobParams = true; } // if we're not specifying complete job info, pass all three of those parms as blank. if (!$specifyJobParams) { $jobName = ''; $jobNumber = ''; $jobUserName = ''; } // Set any non-specified fields to "*ALL". $userData = $userData ? $userData : '*ALL'; $outq = $outq ? $outq : '*ALL'; $userName = $userName ? $userName : '******'; // split up outq in case a library was specified $outqName = ''; $outqLibName = ''; // if an outq was specified but it's not *ALL if ($outq) { $objInfo = splitLibObj(strtoupper($outq)); // IBM i objects are usually upper case $outqName = $objInfo['obj']; $outqLibName = $objInfo['lib']; // if outq is not *ALL, it should have a library name if ($outq != '*ALL' && empty($outqLibName)) { // Try *LIBL $outqLibName = '*LIBL'; // if no libname, result set will be empty, so might as well alert the user. //i5ErrorActivity(I5_ERR_PHP_ELEMENT_MISSING, I5_CAT_PHP, 'Missing outq library', 'You specified an outq but did not qualify it with a library name.'); // return false; } } $apiPgm = 'QGYOLSPL'; /// spool file list $apiLib = 'QSYS'; $lengthOfReceiverVariable = 136; // list entry API will have a receiver DS of this length $paramXml = $connection->getDummyReceiverAndLengthApiXml(1, $lengthOfReceiverVariable) . "\n" . $connection->getListInfoApiXml(3) . "\n" . $connection->getNumberOfRecordsDesiredApiXml(4) . "\n" . $connection->getSortInformationApiXml(5) . "\n" . "<parm io='in' comment='6. Filter information' >\n <ds var='filterInfo' comment='Use format OSPF0100' len='dummy' >\n <data type='10i0' comment='Number of user names'>1</data>\n <data type='10a' comment='User name'>{$userName}</data>\n <data type='2h' comment='Reserved' />\n <data type='10i0' comment='Number of output queue names'>1</data>\n <data type='10a' comment='Output queue name'>{$outqName}</data>\n <data type='10a' comment='Output queue library name'>{$outqLibName}</data>\n <data type='10a' comment='Form type'>*ALL</data>\n <data type='10a' comment='User-specified data'>{$userData}</data>\n <data type='10i0' comment='Number of statuses'>1</data>\n <data type='10a' comment='Spooled file status'>*ALL</data>\n <data type='2h' comment='Reserved' />\n <data type='10i0' comment='Number of printer device names'>1</data>\n <data type='10a' comment='Printer device name'>*ALL</data>\n <data type='2h' comment='Reserved' />\n </ds>\n </parm>\n <parm io='in' comment='7. Qualified job name. Pass blank to ignore.'>\n <ds var='qualifiedJobName' comment='Qualified job name, total length 26'>\n <data var='jobName' type='10a' comment='Job name'>{$jobName}</data>\n <data var='userName' type='10a' comment='User name'>{$jobUserName}</data>\n <data var='jobNumber' type='6a' comment='Job number'>{$jobNumber}</data>\n </ds>\n </parm>\n \n <parm io='in' comment='8. Format of the generated list.'>\n <data var='listFormat' type='8a'>OSPL0300</data>\n </parm>\n" . ToolkitServiceCw::getErrorDataStructXml(9) . "\n<parm io='in' comment='10. Format name'>\n <data var='format' type='8a' comment='Format name of data to receive'>OSPF0100</data>\n </parm>"; // now call it! // pass param xml directly in. $retPgmArr = $connection->PgmCall($apiPgm, $apiLib, $paramXml); if ($connection->getErrorCode()) { i5CpfError($connection->getErrorCode(), $connection->getErrorMsg()); return false; } $retArr = $retPgmArr['io_param']['listinfo']; // 'listinfo' defined in getListInfoApiXml() //d($retArr); $totalRecords = $retArr['totalRecords']; $requestHandle = $retArr['requestHandle']; // receiver data we want to see $receiverDs = "\n <data var='JOBNAME' type='10a' comment='Job name' />\n <data var='USERNAME' type='10a' comment='User name' />\n <data var='JOBNBR' type='6a' comment='Job number' />\n <data var='SPLFNAME' type='10a' comment='Spooled file name' />\n <data var='SPLFNBR' type='10i0' comment='Spooled file number' />\n <data var='SPLFSTAT' type='10i0' comment='Spooled file status' />\n <data var='DATEOPEN' type='7a' comment='Date file was opened (created)' />\n <data var='TIMEOPEN' type='6a' comment='Time file was opened (created)' />\n <data var='SCHED' type='1a' comment='Spooled file schedule' />\n <data var='SYSTNAME' type='10a' comment='Spooled file system name' />\n <data var='USERDATA' type='10a' comment='User-specified data' />\n <data var='FORMTYPE' type='10a' comment='Form type' />\n <data var='OUTQNAME' type='10a' comment='Output queue name' />\n <data var='OUTQLIB' type='10a' comment='Output queue library name' />\n <data var='STORPOOL' type='10i0' comment='Auxiliary storage pool' />\n <data var='SPLFSIZE' type='10i0' comment='Size of spooled file' />\n <data var='SPLFMULT' type='10i0' comment='Spooled file size multiplier' />\n <data var='PAGES' type='10i0' comment='Total pages' />\n <data var='COPILEFT' type='10i0' comment='Copies left to produce' />\n <data var='PRIORITY' type='1a' comment='Priority' />\n <data var='reserved' type='3h' comment='Reserved' />\n <data var='INETPRINT' type='10i0' comment='Internet print protocol job identifier' />"; // from this point on, no CPFs will happen in this function. noError(); // make request for objects, but don't return any yet. // Get a handle and total number of records. // listinfo: totalRecords, firstRecordNumber, requestHandle. if firstRec... < totalRecords then can continue. // return I5_ERR_BEOF when went past last record. get CPF GUI0006 when used invalid record#. $listObj = new ListFromApi($requestHandle, $totalRecords, $receiverDs, $lengthOfReceiverVariable, $connection); return $listObj; }