on 12-11-2014 8:50 AM
I have to rasie exception /IWBEP/CX_MGW_BUSI_EXCEPTION within a backend method, which will be called by the GET_ENTITY method.
I have caught the exception into a reference LR_BUSINESS_EXCEPTION.
lr_exception is the importing parameter for the backend method called.
Should I use the following code
Or should I raise the exceptionas per the below code
In this case how should I populate IIO_MESSAGE_CONTAINER based on the reference LR_BUSINESS_EXCEPTION.
Please advice.
Hi,
Just you have to raise the Business Exception
MO_CONTEXT->GET_MESSAGE_CONTAINER( )->ADD_MESSAGE(
exporting
IV_MSG_TYPE = /iwbep/cl_cos_logger=>WARNING " Message Type
IV_MSG_ID = ' ' " Message Class
IV_MSG_NUMBER = ' ' " Message Number
IV_ADD_TO_RESPONSE_HEADER = ABAP_TRUE "Response to the Header
).
RAISE EXCEPTION TYPE /IWBEP/CX_MGW_BUSI_EXCEPTION
exporting
MESSAGE_CONTAINER = MO_CONTEXT->GET_MESSAGE_CONTAINER( ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Vivek,
Exceptions should not be used as import/export parameters. Business exception will be caught by the Gateway framework and the error message within it will be displayed. You just have to raise the Business exception.
regards
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vivek,
To return a message ->
lo_message_container TYPE REF TO /iwbep/if_message_container.
lo_message_container = mo_context->get_message_container( ).
IF lt_error_out[] IS INITIAL.
lv_msg_text = 'Sales Order not found.'.
CALL METHOD lo_message_container->add_message_text_only
EXPORTING
iv_msg_type = 'E'
iv_msg_text = lv_msg_text.
RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
EXPORTING
message_container = lo_message_container.
ENDIF.
Please check the below which will help you to return back table of messages which comes from Back End.
Regards,
Ashwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If the error/message table which returned by your FM is of type BAPIRET2 then you can directly send as below :
Here BAPIRET2 is the standard structure which will be available and that is the reason we can send directly send as below.
DATA: LO_MECO TYPE REF TO /IWBEP/IF_MESSAGE_CONTAINER.
DATA: LX_BUSI_EXC TYPE REF TO /IWBEP/CX_MGW_BUSI_EXCEPTION.
LO_MECO = MO_CONTEXT->GET_MESSAGE_CONTAINER( ).
LO_MECO->ADD_MESSAGES_FROM_BAPI( IT_BAPI_MESSAGES = LT_ERR_RET_TAB ).
CREATE OBJECT LX_BUSI_EXC
EXPORTING
MESSAGE_CONTAINER = LO_MECO.
RAISE EXCEPTION LX_BUSI_EXC.
where LT_ERR_RET_TAB is your internal table where you would have captured all the error messages and which is of type BAPIRET2.
If the error/message table which returned by your FM is not of type BAPIRET2 ( i.e., custom error table ) then you cannot directly send as shown above.
Your custom error table is not a standard and will not be available in all the systems and hence you need to send back table of messages in a table which is of type BAPIRET2.
You need to get all the necessary details from the custom error table returned by your FM and then populate to a internal table which is of type BAPIRET2 and then send as shown above.
Regards,
Ashwin
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.