0
我已經從SAP中的BAPI創建了一個Webservice,以將一些AccountDocuments插入到SAP中。在這些情況下,系統在成功插入呼叫後需要COMMIT呼叫。這兩個函數都必須在「一個上下文」中調用。 現在我面臨的問題是,我不知道如何在php中執行此操作,或者有任何方法可以執行此操作? 我已經創建了以下示例,但它不起作用。 COMMIT函數被執行,但對SAP沒有影響。我看不到數據庫中的數據,但第一次調用返回「數據成功預訂」。我知道你必須用SAP中的COMMIT調用來確認這一點。在SE37中,可以將2個函數調用放入一個序列中。我正在尋找php方式來做到這一點。SAP和php SOAP COMMIT
function insertAccntDoc($accntgl, $currAmount, $docHeader, $accntTax)
{
#Define Authentication
$SOAP_AUTH = array('login' => SAPUSER,
'password' => SAPPASSWORD);
$WSDL = "url_to_my_wsdl";
#Create Client Object, download and parse WSDL
$client = new SoapClient($WSDL, $SOAP_AUTH);
#Setup input parameters (SAP Likes to Capitalise the parameter names)
$params = array(
'AccountGl' => $accntgl,
'CurrencyAmount' => $currAmount,
'DocumentHeader' => $docHeader,
'AccountTax' => $accntTax
);
#Call Operation (Function). Catch and display any errors
try
{
$result = $client->AcctngDocumentPost($params);
$result = $client->BapiServiceTransactionCommit();
$result->Gebucht = 'Committed';
if(count($result->Return) > 1)
{
$client->BapiServiceTransactionRollback();
$result->Gebucht = 'Rollback';
}
else if($result->Return->item->Type == 'S')
{
try
{
$client->BapiServiceTransactionCommit();
$result->Gebucht = 'Committed';
}
catch(SoapFault $exception)
{
$client->BapiServiceTransactionRollback();
$result->Fehler = "***Caught Exception***<br>".$exception."<br>***END Exception***<br>";
$result->Gebucht = 'Fehler beim Committen';
}
}
}
catch (SoapFault $exception)
{
$client->BapiServiceTransactionRollback();
$result->Fehler = "***Caught Exception***<br>".$exception."<br>***END Exception***<br>";
$result->Gebucht = 'Fehler beim Anlegen';
}
#Output the results
$result->FlexRet = 'insertAccntDoc';
return $result;
}
謝謝!