【问题标题】:SAP and php SOAP COMMITSAP 和 php SOAP 提交
【发布时间】:2014-12-03 23:33:59
【问题描述】:

我已经从 SAP 中的 BAPI 创建了一个 Web 服务,以将一些 AccountDocuments 插入 SAP。在这些情况下,系统需要在成功插入调用后进行 COMMIT 调用。这两个函数都必须在“一个上下文”中调用。 现在我面临的问题是我不知道如何在 php 中执行此操作,或者是否有任何方法可以执行此操作? 我创建了以下示例,但它不起作用。 COMMIT 函数被执行,但它对 SAP 没有影响。尽管第一次调用返回“数据已成功预订”,但我看不到数据库中的数据。我知道您必须通过 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;    
}

谢谢!

【问题讨论】:

    标签: php web-services soap sap commit


    【解决方案1】:

    此链接详细介绍了如何使用“有状态”网络服务。这是共享会话所必需的。

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

    【讨论】:

      猜你喜欢
      • 2016-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多