Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

sapui5 - Can i change in the OData errorhandling the errordetails property?

is there a way to change in the /IWBEP/CX_MGW_BUSI_EXCEPTION the errordetails the property code? Like write my own stuff in there

For Example

enter image description here

question from:https://stackoverflow.com/questions/65829672/can-i-change-in-the-odata-errorhandling-the-errordetails-property

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Raise /iwbep/cx_mgw_busi_exception with custom message

    DATA lr_busi_exception TYPE REF TO /iwbep/cx_mgw_busi_exception.
    DATA lr_mcontainer TYPE REF TO /iwbep/if_message_container.

    DATA lv_message_text TYPE bapi_msg.
    DATA lv_message_attr1 TYPE symsgv.
    DATA lv_message_attr2 TYPE symsgv.
    DATA lv_message_attr3 TYPE symsgv.
    DATA lv_message_attr4 TYPE symsgv.

    CREATE OBJECT lr_busi_exception.
    CALL METHOD lr_busi_exception->get_msg_container
      RECEIVING
        ro_message_container = lr_mcontainer.

    lv_message_text = 'Error'.
    lv_message_attr1 = ''.
    lv_message_attr2 = ''.
    lv_message_attr3 = ''.
    lv_message_attr4 = ''.

    lr_mcontainer->add_message(
      EXPORTING
        iv_msg_type   = 'E'
        iv_msg_id     = 'MY_CUSTOM_CODE'
        iv_msg_number = 001
        iv_msg_text   = lv_message_text
        iv_msg_v1     = lv_message_attr1
        iv_msg_v2     = lv_message_attr2
        iv_msg_v3     = lv_message_attr3
        iv_msg_v4     = lv_message_attr4
    ).

    RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
      EXPORTING
        message_container = lr_mcontainer.

Result:

{
  "error" : {
    "code" : "MY_CUSTOM_CODE/001",
    "message" : {
      "lang" : "de",
      "value" : "Error"
    },
    "innererror" : {
      "application" : {
        "component_id" : "",
        "service_namespace" : "/XXX/",
        "service_id" : "XXX_SRV",
        "service_version" : "0001"
      },
      "transactionid" : "XXXXXXXXXXXXXXXXXXXX",
      "timestamp" : "XXXXXXXXXXXXXXXXXXXXXXXXX",
      "Error_Resolution" : {
        "SAP_Transaction" : "For backend administrators: use ADT feed reader "SAP Gateway Error Log" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details",
        "SAP_Note" : "See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"
      },
      "errordetails" : [
        {
          "code" : "MY_CUSTOM_CODE/001",
          "message" : "Error",
          "propertyref" : "",
          "severity" : "error",
          "transition" : false,
          "target" : ""
        }
      ]
    }
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...