Skip to Content
Jul 02, 2015 at 04:54 PM

Exception /iwbep/cx_mgw_busi_exception and Error handling


Hi dear gurus,

We are working on a FioriApp-like which the main purpose is to create/update Purchase Orders through OData.

We faced many problems, probably due to our lack of SAPUI5 knowledge, but are now able to create and update those POs with SAPUI5 create() method : SAPUI5 SDK - Demo Kit.

The create() method works as expected :

  • it triggers our XXXSE_CREATE_ENTITY from our generated ZCL_YYY_DP_EXT class when we only send the PO header data
  • it triggers our /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY when we send PO header data and its items

We implemented those methods in order to :

  • in the case of XXXSE_CREATE_ENTITY, create PO (using BAPI_PO_CREATE1)
  • int he case of CREATE_DEEP_ENTITY, update PO (using BAPI_PO_CHANGE)

It is now time to handle those BAPIs' returned errors. Message container is used to pass each bapi return to the App :

lre_container = /iwbep/if_mgw_conv_srv_runtime~get_message_container( ).
      iv_msg_type = ls_return-type
      iv_msg_id = ls_return-id
      iv_msg_number = ls_return-number
      iv_msg_text = ls_return-message
      iv_msg_v1 = ls_return-message_v1
      iv_msg_v2 = ls_return-message_v2
      iv_msg_v3 = ls_return-message_v3
      iv_msg_v4 = ls_return-message_v4
      iv_is_leading_message = lv_is_leading_message
      iv_add_to_response_header = abap_true ).

Everything is fine so far but one thing : the SAPUI5 create() method would never trigger the error callback function. So, we tried to raise an exception (/iwbep/cx_mgw_busi_exception) within the ABAP code so the error callback function is executed. The response of our update request changed from "HTTP/1.1 201 Created" to " HTTP/1.1 400 Bad Request". I guess that a normal behavior ?

We are using batch request in order to send multiple requests to our back end.

Here is the response of the back end server :

HTTP/1.1 400 Bad Request
Content-Type: application/json
Content-Length: 2028
location: http://pathToOurService/PurchaseOrdersSet('')
dataserviceversion: 1.0

{"error":{{"code":"/IWBEP/CX_MGW_BUSI_EXCEPTION","message":"Exception survenue sans erreur spécifique","propertyref":"","severity":"error"}]}}}

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1059
dataserviceversion: 2.0


HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 12205
dataserviceversion: 2.0


HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1795
dataserviceversion: 2.0


HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 21317
dataserviceversion: 2.0


This seems to be correct, but actually, the 400 Bad Request error makes our App bugging, like there is no oData service plugged. No more data is displayed...

We then tried to disable the batch mode via : JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.ODataModel

And everything went back.

Why a Bad Request sent in response for a batch update, would disable an entire App ?

Is it possible to send a batch with POST request separated from the GET requests ?

Is the /iwbep/cx_mgw_busi_exception Exception the way we should use to handle the high severity errors ?

Thanks for reading and hope we'll find a solution.