📟saveplaceholder function – replace with the relevant business logic
📟check_msg_and_raise_exceptionsTake a look at Generic Exception handling (BAPIRET2) in OData
METHOD /iwbep/if_mgw_appl_srv_runtime~create_deep_entity.
DATA: lv_entity_set_name TYPE /iwbep/mgw_tech_name.
DATA: ls_entity TYPE z.... "Deep Structure
DATA: lo_message_container TYPE REF TO /iwbep/if_message_container.
DATA: lt_return TYPE bapiret2_t.
lo_message_container = mo_context->get_message_container( ).
lv_entity_set_name = io_tech_request_context->get_entity_set_name( ).
CASE lv_entity_set_name.
WHEN 'EntitySetXYZ'.
*--- read entry data
io_data_provider->read_entry_data( IMPORTING es_data = ls_entity ).
*--- save data
save( IMPORTING et_return = lt_return CHANGING c_data = ls_entity ).
*--- check for errors
check_msg_and_raise_exceptions( it_messages = lt_return i_message_container = lo_message_container ).
*--- copy data to ref
copy_data_to_ref( EXPORTING is_data = ls_entity CHANGING cr_data = er_deep_entity ).
WHEN OTHERS.
super->/iwbep/if_mgw_appl_srv_runtime~create_deep_entity(
EXPORTING
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
io_data_provider = io_data_provider
it_key_tab = it_key_tab
it_navigation_path = it_navigation_path
io_expand = io_expand
io_tech_request_context = io_tech_request_context
IMPORTING
er_deep_entity = er_deep_entity
).
ENDCASE.
ENDMETHOD.
