Esempio n. 1
0
 /**
  * Call QGYGTLE (get list entry) API using handle and "next record to request."
  *
  * Note: if get timing problems where no records are returned:
  * Embed the call to the QGYGTLE API in a do-loop that loops until a record is returned.
  *
  * @return bool Return false when run out of records (get GUI0006 error code).
  */
 public function getNextEntry()
 {
     $apiPgm = 'QGYGTLE';
     $apiLib = 'QSYS';
     $receiverDs = $this->_receiverDs;
     $requestHandle = $this->_requestHandle;
     $lengthOfReceiverVariable = $this->_receiverSize;
     $nextRecordToRequest = $this->_nextRecordToRequest++;
     // assign to me, then increment for next time
     $outputVarname = 'receiver';
     $lenLabel = 'size' . $outputVarname;
     $paramXml = "<parm io='out' comment='1. receiver data'>\n            <ds var='{$outputVarname}' comment='receiver appropriate to whatever API created the list' len='{$lenLabel}'>\n            {$receiverDs}\n            </ds>\n            </parm>\n            <parm io='both' comment='2. Length of receiver variable'>\n            <data var='receiverLen' type='10i0' setlenx='{$lenLabel}'>{$lengthOfReceiverVariable}</data>\n            </parm>\n            <parm io='in' comment='3. Request handle'>\n            <data var='requestHandle' comment='Request handle: binary/hex' type='4b'>{$requestHandle}</data>\n            </parm>\n" . $this->ToolkitSrvObj->getListInfoApiXml(4) . "\n" . "<parm io='in' comment='5. Number of records to return'>\n            <data var='numRecsDesired' type='10i0'>1</data>\n            </parm>\n            <parm io='in' comment='6. Starting record' >\n            <data var='startingRecordNum' comment='First entry number to put in receiver var. If getting one record at a time, increment this each time.' type='10i0'>{$nextRecordToRequest}</data>\n            </parm>\n" . Toolkit::getErrorDataStructXmlWithCode(7);
     // param number 7
     // was getErrorDataStructXml
     // pass param xml directly in.
     $retPgmArr = $this->ToolkitSrvObj->PgmCall($apiPgm, $apiLib, $paramXml);
     if ($this->ToolkitSrvObj->getErrorCode()) {
         return false;
     }
     /* Even when no error reported by XMLSERVICE (->error),
      * we may get a GUI0006 in DS error structure exeption code, since we
      * supplied a full error data structure above (getErrorDataStructXmlWithCode).
      */
     $apiErrCode = $retPgmArr['io_param']['errorDs']['exceptId'];
     if ($apiErrCode != '0000000') {
         // Note: caller can check for GUI0006 and GUI0001 (expected when go past last record) vs. any other error (not expected)
         $this->ToolkitSrvObj->setErrorCode($apiErrCode);
         return false;
     }
     $retArr = $retPgmArr['io_param'][$outputVarname];
     return $retArr;
 }