As we all know how to add filters in GET ENTITY SET (Query) operation, But I got a Requirement in the real-time business scenario to add a filter in the GET (READ) operation for a non-key field to create a user based on the filter value with the combination of GET(read) operation.
Here the sample service with few key steps which are to be followed:
Create a new project :
Import your structure and generate the Runtime objects.
Redefine method “CRUDQSET_GET_ENTITY“.
METHOD crudqset_get_entity. ** -- Data Declarations DATA:lv_opt TYPE /iwbep/s_cod_select_option. ** -- Field Symbols FIELD-SYMBOLS:
TYPE any, TYPE /iwbep/t_mgw_select_option, TYPE string, TYPE /iwbep/t_cod_select_options. ASSIGN mr_request_details->* TO . IF IS ASSIGNED. ASSIGN COMPONENT 'FILTER_SELECT_OPTIONS' OF STRUCTURE TO . IF IS ASSIGNED. LOOP AT ASSIGNING FIELD-SYMBOL( ) . ASSIGN COMPONENT 'PROPERTY' OF STRUCTURE TO . ASSIGN COMPONENT 'SELECT_OPTIONS' OF STRUCTURE TO . IF IS ASSIGNED AND IS ASSIGNED. CASE . ** -- Address WHEN 'Zadrs'. READ TABLE ASSIGNING FIELD-SYMBOL( ) INDEX 1. IF IS ASSIGNED . lv_opt-low = -low. ENDIF. ENDCASE. ENDIF. ENDLOOP. ENDIF. ENDIF. ** -- Get Employee Details based on Employee Id READ TABLE it_key_tab INTO DATA(ls_key_tab) WITH KEY name = 'Zempid'. IF sy-subrc EQ 0. ** -- Get Employee Details based on Employee Id and Employee Address SELECT SINGLE * FROM zodata_crudq INTO er_entity WHERE zempid = ls_key_tab-value. if zadrs = lv_opt-low. ** Do some Validations endif. ENDIF. ENDMETHOD.
URI : http://
Hope the above-furnished information is useful.