Skip to Content

how to get the error message from back-end when using the odata CURD?

Dear friends,

         When we use odata to connect the back-end system like this:  when the get_entity method return a error message, how Do we get the specific message form back-end. in the error function, we can get the response.body, but that was the long string, like this :

<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>/IWBEP/CM_MGW_RT/020</code><message xml:lang="en">Resource not found for segment 'Product'.</message><innererror><application><component_id/><service_namespace>/SAP/</service_namespace><service_id>ZFCRM_ORDER_CREATE_SRV</service_id><service_version>0001</service_version></application><transactionid>572BCB13C69E2F17E10000000A7A0B2D</transactionid><timestamp/><Error_Resolution><SAP_Transaction/><SAP_Note>See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)</SAP_Note></Error_Resolution><errordetails><errordetail><code>/IWBEP/CX_MGW_BUSI_EXCEPTION</code><message>Resource not found for segment 'Product'</message><propertyref/><severity>error</severity><target/></errordetail></errordetails></innererror></error>

My controller code:

var filter = "ProductSet(Dischannel='" + Dischannel +"',Salesorg='" + saleorg + "',Productid='" + product + "')";

  porductOdata.read(filter,null,null,false,

  function(oData){

     that.getView().byId("Description_id").setValue(oData.Description);

  },

     function(oEvent,response){

      str = oEvent.response.body;

      alert(msg);

     }

  );

back-end message:

MESSAGE E010(ZFIORI_ORDER_MSG) INTO LV_MSGTXT

          WITH 'Product'.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    May 06, 2016 at 06:00 AM

    Hi Zhang,

    Ideally the backend error will be thrown either with the exceptions or BAPI return parameter. In this case from UI, you need to bind the exceptions and handle it, in order to show as error message.

    Also check this thread :


    Regards,

    Tejas

    Add comment
    10|10000 characters needed characters exceeded