/** * sapLogout * * @return void * @access private */ public function sapLogout() { if ($this->sapMod != null) { foreach ($this->sapMod as $key => $value) { saprfc_function_free($this->sapMod[$key]); } $this->sapMod = null; } if ($this->sapRfc != null) { saprfc_close($this->sapRfc); $this->sapRfc = null; } }
/** * Check if RFC connection is valid * * @return SAPRFC_OK on success, <> SAPRFC_OK on failure */ function IsConnectionLive() { if ($this->rfc == false) { return $this->SetStatus(SAPRFC_ERROR, "SAPConnection::IsConnectionLive: No valid RFC handle"); } $fce = @saprfc_function_discover($this->rfc, "RFC_PING"); if ($fce == false) { return $this->SetStatus(SAPRFC_ERROR, @saprfc_error()); } $rc = @saprfc_call_and_receive($fce); @saprfc_function_free($fce); if ($rc == SAPRFC_OK) { return $this->SetStatus(SAPRFC_OK, ""); } else { return $this->SetStatus(SAPRFC_ERROR, @saprfc_error()); } }
/** * Close function module free, resources * */ function Close() { if ($this->def) { $this->InitVars(true); unset($this->def); } if ($this->server == false && $this->fce) { @saprfc_function_free($this->fce); } $this->fce = false; $this->rfc = false; $this->name = ""; }
public function close($fce, $rfc) { saprfc_function_free($fce); saprfc_close($rfc); }
public function __destruct() { saprfc_function_free($this->func); saprfc_close($this->conn); }
exit; } saprfc_import ($fce,"PROGRAM",$REPORT); saprfc_table_init ($fce,"QTAB"); $rc = saprfc_call_and_receive ($fce); if ($rfc_rc != SAPRFC_OK) { if ($rfc == SAPRFC_EXCEPTION ) echo ("Exception raised: ".saprfc_exception($fce)); else echo ("Call error: ".saprfc_error($fce)); exit; } $SYSTEM = saprfc_export ($fce,"SYSTEM"); $TRDIR = saprfc_export ($fce,"TRDIR"); $rows = saprfc_table_rows ($fce,"QTAB"); echo "<PRE>"; for ($i=1; $i<=$rows; $i++) { $QTAB = saprfc_table_read ($fce,"QTAB",$i); echo ($QTAB[LINE]."\n"); } echo "</PRE>"; saprfc_function_free($fce); saprfc_close($rfc); ?>
/** * @param SAP_Module_Abstract $module * * @throws Exception * @return array * @author Manuel Will * @since 2013 */ public function executeSave(SAP_Module_Abstract $module) { $this->storeDebugTraceToStatic(); $moduleName = $module->getModuleName(); $moduleResource = $this->getModuleResource($moduleName); $receivedData = @saprfc_call_and_receive($moduleResource); $this->checkStatusCode($receivedData, $moduleResource); /** * Ein Commit kann trotzdem stattfinden, obwohl ein Resultat zurückkommt. * Ein Rollback braucht es eigentlich nur beim Fehler, der wirklich ein Fehler ist. Der Fehler würde dann aber schon * in $this->checkStatusCode eine Exception werfen. Möglicherweise erübrigt sich ein Rollback eigentlich immer. Hier sollte wohl immer * Array zurückkommen weshalb das nur mit if ($var) geprüft wurde. Bei manchen Bausteinen kommt es wohl vor, dass auch -1 zurück kommen kann. * Das heißt, es kommt ein "Fehlerresult" zurück, aber nicht als Array sondern als "-1". Das ist offensichtlich kein Fehler. */ $mxdResult = saprfc_table_rows($moduleResource, 'RETURN'); if ($mxdResult && $mxdResult != -1) { $moduleResource2 = saprfc_function_discover($this->getConnectionResource(), 'BAPI_TRANSACTION_ROLLBACK'); $errorCode = saprfc_call_and_receive($moduleResource2); $this->checkStatusCode($errorCode, $moduleResource2); } else { $moduleResource2 = saprfc_function_discover($this->getConnectionResource(), 'BAPI_TRANSACTION_COMMIT'); $errorCode = saprfc_call_and_receive($moduleResource2); $this->checkStatusCode($errorCode, $moduleResource2); } $successState = @saprfc_table_read($moduleResource, 'RETURN', 1); // if (!empty($successState['TYPE']) && $successState['TYPE'] == 'E') { throw new SAP_Exception(json_encode($successState)); } $result = array(); $this->appendExporter($result, $moduleResource, $module->getExporter()); // saprfc_function_debug_info($moduleConnection); saprfc_function_free($moduleResource); if (PHP_SAPI == 'cli') { echo print_r($this->debug) . PHP_EOL; } return array('transactionSuccess' => false === $successState, 'export' => $result); // d.h. insert hat funktioniert! }