SAP and php SOAP COMMIT


SAP and php SOAP COMMIT

我已经从SAP中的BAPI创建了一个Web服务,以便将一些AccountDocument插入SAP中。在这些情况下,系统需要在成功插入调用之后进行COMMIT调用。这两个函数都必须在";一个上下文";。

现在我面临的问题是,我不知道如何在php中实现这一点,或者是否有任何方法可以实现这一目标?

我创建了以下示例,但它不起作用。COMMIT函数被执行,但它在SAP中没有影响。我看不到数据库中的数据,尽管第一个调用返回"0";数据已成功预订";。我知道您必须通过SAP中的COMMIT呼叫来确认这一点。在SE37中,有一种方法可以将2个函数调用放入一个序列中。我正在搜索php方法来完成这项工作。

    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;    
}

谢谢!

此链接提供了有关如何使用"有状态"web服务的详细信息。这是共享会话所必需的。

http://scn.sap.com/thread/140909