on 04-03-2014 9:31 AM
Hi,
I am new to sap gateway. Currently i am creating a Odata Service through the transaction SEGW. In the query i have mapped a RFC. When i execute the service sometimes the RFC throws exception like 'No data Found'. But i dont know how to capture the exception returned from the RFC.
I read some threads which says use
RAISE EXCEPTION TYPE /IWBEP/CX_MGW_BUSI_EXCEPTION
EXPORTING
textid = /iwbep/cx_mgw_busi_exception=>business_error
message = lv_text
message_container = io_message_container.
My doubt is since i have not done any code in the DPC method. As said in many threads should i go to DPC_EXT method and redefine the method or how to capture the exception.
Kindly advise. Thanks in advance
Hello Velsankar,
You need not to capture the error messages explicitly by writing custom code in you DPC_EXT if you are using service builder when the return error message table is of type BAPIRET2.
GW itself will handle and return the error messages.
If at all the return error message table is of different type , i mean to say if it is not of type BAPIRET2 then you need to capture explicitly.
The below is the code you need to write in DPC_EXT to capture.
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.
Note : where LT_ERR_RET_TAB is your internal table where you would have captured all the error messages.
That is it. You will be able to see the messages .
Regards,
Ashwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You need not to capture the messages explicitly by writing custom code in you DPC_EXT class, refer below code,
login page example,
"" Message container declaration.
DATA: LO_MESSAGE_CONTAINER TYPE REF TO /IWBEP/IF_MESSAGE_CONTAINER.
""If login successful, success message will be displayed.
IF ER_ENTITY IS NOT INITIAL.
CALL METHOD ME->/IWBEP/IF_MGW_CONV_SRV_RUNTIME~GET_MESSAGE_CONTAINER
RECEIVING
RO_MESSAGE_CONTAINER = LO_MESSAGE_CONTAINER. " Message Container Interface
CALL METHOD LO_MESSAGE_CONTAINER->ADD_MESSAGE
EXPORTING
IV_MSG_TYPE = /IWBEP/CL_COS_LOGGER=>SUCCESS " Message Type
IV_MSG_ID = 'ZVIT_LOGIN' " Message Class
IV_MSG_NUMBER = '001' " Message Number
IV_ADD_TO_RESPONSE_HEADER = ABAP_TRUE. " Flag for adding or not the message to the response header
""""""If login failed error message will displayed.
ELSE.
CALL METHOD ME->/IWBEP/IF_MGW_CONV_SRV_RUNTIME~GET_MESSAGE_CONTAINER
RECEIVING
RO_MESSAGE_CONTAINER = LO_MESSAGE_CONTAINER. " Message Container Interface
CALL METHOD LO_MESSAGE_CONTAINER->ADD_MESSAGE
EXPORTING
IV_MSG_TYPE = /IWBEP/CL_COS_LOGGER=>ERROR " Message Type
IV_MSG_ID = 'ZVIT_LOGIN' " Message Class
IV_MSG_NUMBER = '002' " Message Number
IV_ADD_TO_RESPONSE_HEADER = ABAP_TRUE. " Flag for adding or not the message to the response header
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Velsankar,
If you want to handle something which has not been done in the generated DPC class, then you can go to DPC_EXT class, redefine and copy the whole implementation that was in DPC and modify/change what you need to.
Best regards,
Aakash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
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.