on 05-04-2018 8:29 AM
I am passing values from Front end to odata service for creation of PM Order Confirmation . if that bapi is returning any error message how to pass those error messages to front end.
You have to check the BAPI return table for errors, add them to a message container and use that to throw the exception:
DATA: lt_errors TYPE STANDARD TABLE OF bapiret2.
" Collect Errors
LOOP AT lt_return ASSIGNING FIELD-SYMBOL(<fs_return>) WHERE type = 'E'.
APPEND <fs_return> TO lt_errors.
ENDLOOP.
IF lt_errors IS NOT INITIAL.
DATA(lr_msg_cont) = /iwbep/cl_mgw_msg_container=>get_mgw_msg_container( ).
lr_msg_cont->add_messages_from_bapi(
EXPORTING
it_bapi_messages = lt_errors " Return parameter table
).
RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
EXPORTING
message_container = lr_msg_cont.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is recommended to use your own exception class that inherits from /iwbep/cx_mgw_busi_exception. This way it is more clear that your exceptions stem from your application rather than from the SAP Gateway framework.
CLASS zcx_zdx271_busi_exception DEFINITION
PUBLIC
INHERITING FROM /iwbep/cx_mgw_busi_exception
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
METHODS constructor
IMPORTING
!textid LIKE if_t100_message=>t100key OPTIONAL
!previous LIKE previous OPTIONAL
!message_container TYPE REF TO /iwbep/if_message_container OPTIONAL
!http_status_code TYPE /iwbep/mgw_http_status_code DEFAULT gcs_http_status_codes-bad_request
!http_header_parameters TYPE /iwbep/t_mgw_name_value_pair OPTIONAL
!sap_note_id TYPE /iwbep/mgw_sap_note_id OPTIONAL
!msg_code TYPE string OPTIONAL
!entity_type TYPE string OPTIONAL
!message TYPE bapi_msg OPTIONAL
!message_unlimited TYPE string OPTIONAL
!filter_param TYPE string OPTIONAL
!operation_no TYPE i OPTIONAL .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcx_zdx271_busi_exception IMPLEMENTATION.
METHOD constructor
CALL METHOD super->constructor
EXPORTING
previous = previous
message_container = message_container
http_status_code = http_status_code
http_header_parameters = http_header_parameters
sap_note_id = sap_note_id
msg_code = msg_code
entity_type = entity_type
message = message
message_unlimited = message_unlimited
filter_param = filter_param
operation_no = operation_no.
CLEAR me->textid.
IF textid IS INITIAL.
if_t100_message~t100key = if_t100_message=>default_textid.
ELSE.
if_t100_message~t100key = textid.
ENDIF.
ENDMETHOD.
ENDCLASS.
To further augment Andre's saying an example can be found here
andre.fischer
As per my experiment this cannot be implemented in RAP programming .
When we are using IF_RAP_QUERY_PROVIDER (not behavior implementation ) .
I mean when we are using the below way of implementing RAP in BTP ,
Whenever we use /iwbep/cl_mgw_msg_container it says , usage is not allowed .
Is my understanding right
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.