cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to find if_sadl_gw_query_control ~ set_query_options in my DPC / DPC_EXT Class

ajith_c
Explorer
0 Kudos

Hi experts,

I have developed an ODATA service based on a CDS View by following the steps in the document below.

Generating an OData Service Based on a Referenced Data Source

Now, I am trying to follow the steps mentioned in the document below to read the query options.

Access the Query Options

However, I do not find the interface if_sadl_gw_query_control in my DPC / DPC_EXT class as mentioned in the above document.

Am I doing anything wrong here? Any suggestions would be highly helpful.

Thanks,

Ajith

Accepted Solutions (0)

Answers (4)

Answers (4)

ivo_skolek
Explorer

Hi Ajith and Filip,

I was now looking to exactly same issue. I have OData based on "referenced data source" and needed to change 1 of the filter criteria from "equal to" to "contains pattern" before passing to SADL. One colleague kindly provided solution by "cloning" the request in *DPC_EXT and changing the request data before passing to SADL. That works well. Would be nice if someone from SAP can confim if this is a safe approach. And if not provide please more details how to achieve similar behaviour from the frontend side (I am using Smart Filterbar)

METHOD zcfi_vendor_comp_get_entityset.


    DATA: lo_tech_request_clone TYPE REF TO /iwbep/cl_mgw_request,
          lt_headers            TYPE tihttpnvp,
          lr_request            TYPE REF TO /iwbep/if_mgw_core_srv_runtime=>ty_s_mgw_request_context.


    "as we need to adjust the request we will create a "clone" of request, adjust what is necessary
    "and then pass it to SADL framework
    DATA(ls_request) = CAST /iwbep/cl_mgw_request( io_tech_request_context )->get_request_details( ).


    "for payment methods "selection criteria" needs to be adjusted from "equal" to "contains"
    "means if frontend sends "eq A" we need to change to "cp *A*"
    ASSIGN ls_request-technical_request-filter_select_options[ property = 'PAYMENT_METHODS' ] TO FIELD-SYMBOL(<lt_payment_meth_selopt>).
    IF sy-subrc EQ 0.
      LOOP AT <lt_payment_meth_selopt>-select_options ASSIGNING FIELD-SYMBOL(<ls_selopt>)
          WHERE sign = 'I' AND option = 'EQ'.
        <ls_selopt>-option = 'CP'.
        <ls_selopt>-low = '*' && <ls_selopt>-low && '*'.
      ENDLOOP.
    ENDIF.


    GET REFERENCE OF ls_request INTO lr_request.
    DATA(lo_model_fw) = CAST /iwbep/if_mgw_odata_fw_model( CAST /iwbep/cl_mgw_dp_facade( me->/iwbep/if_mgw_conv_srv_runtime~get_dp_facade( )
                                                         )->/iwbep/if_mgw_dp_int_facade~get_model( ) ).


    lo_tech_request_clone = NEW #( ir_request_details = lr_request it_headers = lt_headers io_model = lo_model_fw ).


    "call super - let SADL do the selection
    CALL METHOD super->zcfi_vendor_comp_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_tech_request_clone
      IMPORTING
        et_entityset             = et_entityset
        es_response_context      = es_response_context.


  ENDMETHOD.
dominik_ee
Advisor
Advisor
0 Kudos

Hi Ajith,

setting the query options is only available in MDS Scenarios (Mapped Data Source) as stated on the landing page: https://help.sap.com/viewer/23969e5c00e1475283553381af0b1a12/latest/en-US/d408fde4fdb34c6f81e66cb82b...

Please make sure that all the entities in your SEGW project are mapped data sources and not referenced. Otherwise this feature will not be available.

Best regards,
Dominik

0 Kudos

Hi Ajith,

If you are able to map the Entity to a CDS properly then if_sadl_gw_query_control interface will be available for redefining

Regards,

Toney C Benoy

filipn
Employee
Employee
0 Kudos

Hi Ajith,

If you create or generate Odata services as Reference Data Source, you will not find if_sadl_gw_query_control~set_query_options in DPC/DPC_EXT classes. There is some option how to manipulate with the queries in OData but it is strongly not recommended.

The best practice with Reference Data Source:

1) modify CDS views and do everything in CDS

2) modify Fiori App, pass parameters to CDS Views (in that case no modification is needed in OData, OData classes will take that parameter and pass it automatically to CDS )

Regards,

Filip