我可以更改 OData 错误处理错误详细信息 属性 吗?
Can i change in the OData errorhandling the errordetails property?
有没有办法更改 /IWBEP/CX_MGW_BUSI_EXCEPTION
属性 code
的错误详细信息?喜欢在那里写我自己的东西
例如
使用自定义消息
提高/iwbep/cx_mgw_busi_exception
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.
结果:
{
"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" : ""
}
]
}
}
}
有没有办法更改 /IWBEP/CX_MGW_BUSI_EXCEPTION
属性 code
的错误详细信息?喜欢在那里写我自己的东西
例如
使用自定义消息
提高/iwbep/cx_mgw_busi_exception
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.
结果:
{
"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" : ""
}
]
}
}
}