日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SAP OData $batch processing

發布時間:2023/12/10 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SAP OData $batch processing 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

例として、1回の呼び出しで100個の新しい商品を作成したい場合、最も簡単な方法は、$ batch要求を使用して100個のPOST呼び出しすべてを単一のサービス呼び出しにまとめることです。

URIの末尾にsap-statistics = trueオプションを追加すると、所要時間についての詳細が表示されます。 SAPゲートウェイのパフォーマンストレースで結果を調べることができます。

(Transaction:/ n/iwfnd/traces?or?/niwbep/traces)

SAP Gateway Side

メソッドCHANGESET_BEGINを使用すると、新しい変更パラメータCV_DEFER_MODEが一度に処理できるゲートウェイフレームワークになります(遅延処理)。 この方法を実行するときの簡単な例を見てみましょう。

  • Transaction /nsegw
  • ランタイム成果物を展開します。
  • dpc_extクラスをダブルクリックして
  • / IWBEP / IF_MGW_APPL_SRV_RUNTIME?CHANGESET_BEGINメソッドを見つけて、再定義してください。
  • その後、これを行うと、CHANGESET_BEGINメソッドは/ IWBEP / IF_MGW_APPL_SRV_RUNTIMEインターフェースから継承されます。

    METHOD /iwbep/if_mgw_appl_srv_runtime~changeset_begin. LOOP AT it_operation_info INTO DATA(ls_operation_info).IF ( ls_operation_info-entity_set EQ 'YourEntitySet' ANDls_operation_info-entity_type EQ 'YourEntity' ).cv_defer_mode = abap_true.EXIT.ENDIF.ENDLOOP.ENDMETHOD.

      

    /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_PROCESS?

    METHOD /iwbep/if_mgw_appl_srv_runtime~changeset_process.DATA: ls_changeset_request TYPE /iwbep/if_mgw_appl_types=>ty_s_changeset_request,ls_changeset_req_parent TYPE /iwbep/if_mgw_appl_types=>ty_s_changeset_request,lo_create_context TYPE REF TO /iwbep/if_mgw_req_entity_c,lv_entity_type TYPE string,ls_changeset_response TYPE /iwbep/if_mgw_appl_types=>ty_s_changeset_response,ls_changeset_resp_parent TYPE /iwbep/if_mgw_appl_types=>ty_s_changeset_response,ls_item TYPE zcl_example_mpc=>ts_item,lv_error_entity TYPE string,lt_return TYPE STANDARD TABLE OF bapiret2.DATA lo_container TYPE REF TO /iwbep/if_message_container.DATA lr_return TYPE REF TO bapiret2.DATA lv_process_count TYPE i.DATA lv_isapproved TYPE xfeld.DATA lv_pending_status TYPE xfeld.**halilu 20.08.2018 16:50:56 ZCL_''_EXT==CM009LOOP AT it_changeset_request INTO ls_changeset_request.** You need to pass it if operation_type is 'PE', because ** $batch comes with unnecessary scenarios, you need to avoid it.IF ls_changeset_request-operation_type EQ 'PE'.CONTINUE.ENDIF.lo_create_context ?= ls_changeset_request-request_context.lv_entity_type = lo_create_context->get_entity_type_name( ).REFRESH : lt_return.* Authority Control if you have a authority scenario, you can code in here.*--------------------------------------------------------------------**--------------------------------------------------------------------*CASE lv_entity_type. *--------------------------------------------------------------------*WHEN 'YourEntity'.CLEAR ls_item.ls_changeset_request-entry_provider->read_entry_data( IMPORTING es_data = ls_item ).** In here , you can implement your logic in a specific customers requirements.** Your code have to return bapiret2_tt parameter as export, ** Because you need to handle errors in here like below.LOOP AT lt_return TRANSPORTING NO FIELDS WHERE type EQ 'E'. ENDLOOP.IF sy-subrc EQ 0.READ TABLE lt_return REFERENCE INTO lr_return INDEX 1.IF sy-subrc EQ 0 ANDlr_return IS BOUND.lo_container = me->mo_context->get_message_container( ).lo_container->add_message_from_bapi(EXPORTINGis_bapi_message = lr_return->*iv_message_target = ls_item-your_key && 'Where you receive errors').ENDIF.RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exceptionEXPORTINGtextid = /iwbep/cx_mgw_busi_exception=>business_errormessage_container = lo_container.ELSE.copy_data_to_ref(EXPORTINGis_data = ls_itemCHANGINGcr_data = ls_changeset_response-entity_data ).ENDIF. *--------------------------------------------------------------------*ENDCASE.ls_changeset_response-operation_no = ls_changeset_request-operation_no.INSERT ls_changeset_response INTO TABLE ct_changeset_response.** If you do something when batch operation finishes, do something like below.AT LAST.** Your Logic ** ENDAT.ENDLOOP.ENDMETHOD.

      

    /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_END?

    METHOD /iwbep/if_mgw_appl_srv_runtime~changeset_end.COMMIT WORK AND WAIT.ENDMETHOD.

      

    SAP Ui5 Side

    最初に、以下のようにoDataModelを設定する必要があります。

    var oConfig = {metadataUrlParams: {},json: true,// loadMetadataAsync : true,defaultBindingMode: "OneWay",defaultCountMode: "None",useBatch: true};// Create and set domain model to the componentvar oModel = new sap.ui.model.odata.v2.ODataModel(sServiceUrl, oConfig);this.setModel(oModel);

      

    その後、必要に応じて$ batch処理を実裝できます。 私はそれのすべてをsap.m.tableを書かなかった、あなたはこのリンクでそれをチェックすることができる。

    SAPUI5 Explored

    In your view , you need to bind oViewModel that is a json Model like this.<Table id="yourTableId" items="{ path: 'oViewModel>/yourArray' }" class="sapUiSizeCompact">

      

    コントローラで、onInit関數でoViewModelをインスタンス化します。

    this_oView = this.getView();var oViewModel = new sap.ui.model.json.JSONModel({yourArray: [{ "field1" : "data11","field2" : "data12","field3" : "data13"},{ "field1" : "data21","field2" : "data22","field3" : "data23"}]});this._oView.setModel(oViewModel, "oViewModel");

      

    _getViewModel: function() {var oViewModel = this._oView.getModel("oViewModel");return oViewModel;},yourFunction: function() {debugger;var oModel = this.getView().getModel(),oTable = this._oTable, // Your Table that you will get item's data.iLength = oTable.getItems("items").length,oItem,sPath,bError = false;// Distinguish your request from other batch requests like below.oModel.setDeferredBatchGroups(["myId"]);for (var i = 0; i < iLength; i++) {var oEntry = {},oParams = {};// You need to show your message that returns from backend the latest.if (i === (iLength - 1)) {oParams.success = function(oData, oResponse) {sap.ui.core.BusyIndicator.hide();MessageToast.show(this._oResourceBundle.getText("PROCESS_SUCCESS"));// debugger;}.bind(this);oParams.error = function(oError) {// debugger;sap.ui.core.BusyIndicator.hide();var oJson = JSON.parse(oError.responseText);this._bIsError = true;var oJson = JSON.parse(oError.responseText);var oMsgBox = sap.ca.ui.message.showMessageBox({type: sap.ca.ui.message.Type.ERROR,message: oJson.error.message.value});if (!sap.ui.Device.support.touch) {oMsgBox.addStyleClass("sapUiSizeCompact");}oModel.refresh();}.bind(this);}oParams.async = false;oParams.batchGroupId = "myId";oItem = oTable.getItems("items")[i];sPath = oItem.getBindingContextPath();// needing to bind yourSpecific Json Model to Table's item aggregation. // in this scenario, oEntry = this._getViewModel().getProperty(oItem.getBindingContextPath());sap.ui.core.BusyIndicator.show(0);oModel.create("/YourEntitySet", oEntry, oParams);}if (bError === true) {return;}oModel.submitChanges({groupId: "myId"}); }

      

    參考文獻

    oData $batch processing

    轉載于:https://www.cnblogs.com/yjyongil/p/10689743.html

    總結

    以上是生活随笔為你收集整理的SAP OData $batch processing的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。