If your service combines entity sets that are not mapped by SADL to a data source
(non-SADL entities) and entity sets mapped by SADL (SADL entities), you can optimize $expand for
associations mapped by SADL, if any exist.
Prerequisites
This feature is available since
SAP NetWeaver 7.4 SP10.
Context
- You have to handle navigation manually.
- You have to store the navigation information in the get_expanded_entity
and get_expanded_entityset methods because the standard getter methods
are not called.
- You have to call the superclass get_expanded_entity and
get_expanded_entityset methods to enable the default implementation of
$expand by the Gateway runtime.
Procedure
- Follow the steps described in the Handling OData Navigation
section.
- Create class instance attributes to store the navigation information.
- Save the navigation information in the get_entity and
get_entityset methods.
- Interpret the navigation in the set_query_options method.
- Remember the navigation information and call the superclass method in the method
get_expanded_entity:
METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entity.
" -------------------------------------------------
mt_navigation_info = io_tech_request_context->get_navigation_path( ).
mt_source_keys = io_tech_request_context->get_source_keys( ).
" ...
" -------------------------------------------------
" Read entity data (and expand), if mapped by SADL
if_sadl_gw_dpc_util~get_dpc( )->get_expanded_entity(
EXPORTING io_expand_node = io_expand
io_tech_request_context = io_tech_request_context
IMPORTING er_entity = er_entity
et_expanded_tech_clauses = et_expanded_tech_clauses
es_response_context = es_response_context
ev_entity_mapped_by_sadl = DATA(lv_entity_mapped) ).
" Entity sets not mapped to a business entity are handled as usual by the DPC
IF lv_entity_mapped <> abap_true.
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_navigation_path = it_navigation_path
it_key_tab = it_key_tab
io_expand = io_expand
io_tech_request_context = io_tech_request_context
IMPORTING er_entity = er_entity
et_expanded_clauses = et_expanded_clauses
et_expanded_tech_clauses = et_expanded_tech_clauses
es_response_context = es_response_context ).
ENDIF.
ENDMETHOD.
- Remember the navigation information and call the superclass method in the
get_expanded_entityset method:
METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset.
" -------------------------------------------------
mt_navigation_info = io_tech_request_context->get_navigation_path( ).
mt_source_keys = io_tech_request_context->get_source_keys( ).
" ...
" -------------------------------------------------
" Read entity data (and expand), if mapped by SADL
if_sadl_gw_dpc_util~get_dpc( )->get_expanded_entityset(
EXPORTING io_expand_node = io_expand
io_tech_request_context = io_tech_request_context
IMPORTING er_entityset = er_entityset
et_expanded_tech_clauses = et_expanded_tech_clauses
es_response_context = es_response_context
ev_entity_mapped_by_sadl = DATA(lv_entity_mapped) ).
" Entity sets not mapped to a business entity are handled as usual by the DPC
IF lv_entity_mapped <> abap_true.
super->/iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset(
EXPORTING iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
it_filter_select_options = it_filter_select_options
it_order = it_order
is_paging = is_paging
it_navigation_path = it_navigation_path
it_key_tab = it_key_tab
iv_filter_string = iv_filter_string
iv_search_string = iv_search_string
io_expand = io_expand
io_tech_request_context = io_tech_request_context
IMPORTING er_entityset = er_entityset
et_expanded_clauses = et_expanded_clauses
et_expanded_tech_clauses = et_expanded_tech_clauses
es_response_context = es_response_context ).
ENDIF.
ENDMETHOD.
Note
If the key fields of your source entity set have a conversion exit (for example,
Alpha Conversion), you need to call get_converted_source_keys( )
instead of get_source_keys( ).