Code template for redefinition of /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITY

📟 get_expanded_entity
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~get_expanded_entity.
    DATA: lo_message_container TYPE REF TO /iwbep/if_message_container,
          lv_entity_name       TYPE /iwbep/mgw_tech_name,
          ls_entity            TYPE z...,
          lt_return            TYPE bapiret2_t.

*--- Basic requirements
    lo_message_container = mo_context->get_message_container( ).
    lv_entity_name = io_tech_request_context->get_entity_type_name( ).

    CASE lv_entity_name.
      WHEN 'ExpandedEntity'.

*--- read keys
        io_tech_request_context->get_converted_keys(
          IMPORTING
            es_key_values = ls_entity
        ).

*--- execute business logic
        get_expanded_entity(
          EXPORTING
            is_entity     = ls_entity
          IMPORTING
            et_return    = lt_return
            es_entity    = ls_entity
        ).

*--- check for errors
        check_msg_and_raise_exceptions(
          EXPORTING
            it_messages                  = lt_return
            io_message_container         = lo_message_container
          ).

*--- copy data to ref
        copy_data_to_ref(
          EXPORTING
            is_data = ls_entity
          CHANGING
            cr_data = er_entity
        ).

      WHEN OTHERS.
        CALL METHOD super->/iwbep/if_mgw_appl_srv_runtime~get_expanded_entity
          EXPORTING
            iv_entity_name           = iv_entity_name
            iv_entity_set_name       = iv_entity_set_name
            iv_source_name           = iv_source_name
            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_entity                = er_entity
            es_response_context      = es_response_context
            et_expanded_clauses      = et_expanded_clauses
            et_expanded_tech_clauses = et_expanded_tech_clauses.
    ENDCASE.

*--- Arrange expand closure
    DATA(lt_children) = io_expand->get_children( ).
    LOOP AT lt_children ASSIGNING FIELD-SYMBOL(<ls_child>).
      APPEND <ls_child>-tech_nav_prop_name TO et_expanded_tech_clauses.
    ENDLOOP.

  ENDMETHOD.

Leave a Reply

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