Technical Articles
How to modify filters in GATEWAY DPC EXT class before GET ENTITY_SET
In some cases we need to modify the filter options in DPC EXT class before it execute GET ENTITY_SET method,
so how to modify the filter options and make them work? follow the following steps:
( you could find sample code in class method /US4G/CL_METERREAD_DAT_DPC_EXT => XUS4GXC_METERR02_GET_ENTITYSET and /US4G/CL_METERREAD_DAT_DPC_EXT => XUS4GXC_MALO_MEL_GET_ENTITYSET )
1) cast the object io_tech_request_context to type of /iwbep/cl_mgw_request:
DATA(lo_tech_request_context) = CAST /iwbep/cl_mgw_request( io_tech_request_context ).
2) get the structure of request details by calling lo_tech_request_context->get_request_details( ) into a local structure ls_request_details:
DATA(ls_request_details) = lo_tech_request_context->get_request_details( ).
3) writhe your own logic to construct filter options, and fill them into structure ls_request_details–technical_request–filter_select_options,
important: clear the structure ls_request_details–technical_request–filter_expressions ls_request_details–technical_request–filter_functions if your are query root entity;
clear the structure ls_request_details–technical_request–navigation_path if your are query a navigation entity set to avoid query root entity again.
them must be cleared otherwise the modified filters won’t work.
*** modify the structure ls_request_details-technical_request-filter_select_options ***
CLEAR cs_request_details-technical_request-navigation_path.
CLEAR: cs_request_details-technical_request-filter_expressions, cs_request_details-technical_request-filter_functions.
4) create an new lo_model object by calling method /iwbep/cl_mgw_med_provider=>get_med_provider( )->get_service_metadata, passing the service name and version:
DATA(lo_med_provider) = /iwbep/cl_mgw_med_provider=>get_med_provider( ).
DATA(lo_model) = lo_med_provider->get_service_metadata(
EXPORTING iv_internal_service_name = '****SRV'
iv_internal_service_version = '0001' ).
5) create an new lo_new_tech_request_context by using constructor of class /iwbep/cl_mgw_request, and passing the ls_request_details and lo_model:
ro_tech_request = NEW /iwbep/cl_mgw_request(
ir_request_details = REF #( is_request_details )
it_headers = VALUE #( )
io_model = CAST #( lo_model ) ).
6) finally pass the new object lo_new_tech_request_context to super class’s GET ENTITY_SET method:
TRY.
CALL METHOD super->xus4gxc_malo_mel_get_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
is_paging = is_paging
it_key_tab = it_key_tab
it_navigation_path = it_navigation_path
it_order = it_order
iv_filter_string = iv_filter_string
iv_search_string = iv_search_string
io_tech_request_context = lo_new_tech_request_context
IMPORTING
et_entityset = et_entityset
es_response_context = es_response_context.
CATCH /iwbep/cx_mgw_busi_exception.
CATCH /iwbep/cx_mgw_tech_exception.
ENDTRY.