Code template for redefinition of /IWBEP/IF_MGW_APPL_SRV_RUNTIME~EXECUTE_ACTION

📟 execute_action
Placeholder function – replace with the relevant business logic

📟 check_msg_and_raise_exceptions

Take a look at Generic Exception handling (BAPIRET2) in OData

  METHOD /iwbep/if_mgw_appl_srv_runtime~execute_action.
    DATA: lv_action_name       TYPE /iwbep/mgw_tech_name,
          lt_parameters        TYPE /iwbep/t_mgw_name_value_pair,
          lo_message_container TYPE REF TO /iwbep/if_message_container,
          lv_propertya         TYPE string,
          lt_return            TYPE bapiret2_t.

*--- basic requirements
    lv_action_name = io_tech_request_context->get_function_import_name( ).
    lt_parameters = io_tech_request_context->get_parameters( ).
    lo_message_container = mo_context->get_message_container( ).

    CASE lv_action_name.

*--- When ActionXYZ do the following
      WHEN 'ActionXYZ'.
        lv_propertya  = lt_parameters[ name = 'PROPERTYA' ]-value.

*-- execute action - execute business logic
        execute_action(
          EXPORTING
            iv_propertya = lv_propertya
          IMPORTING
            et_return    = lt_return
        ).

*--- 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 = lv_propertya "returning data
                          CHANGING  cr_data = er_data ).

      WHEN OTHERS.
        super->/iwbep/if_mgw_appl_srv_runtime~execute_action(
          EXPORTING
            iv_action_name          = iv_action_name
            it_parameter            = it_parameter
            io_tech_request_context = io_tech_request_context
          IMPORTING
            er_data                 = er_data
        ).
    ENDCASE.
  ENDMETHOD.

Leave a Reply

Your email address will not be published. Required fields are marked *