Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Filter System Query Option ($filter) in GET_ENTITY

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.

Output :

URI : http:///sap/opu/odata/sap/ZCRUDQ_SRV/CRUDQSet(‘800574’)?$filter=Zadrs eq ‘BANGALORE’&$format=json

Hope the above-furnished information is useful.



This post first appeared on Web Service Testing A Blackjack GUI And API, please read the originial post: here

Share the post

Filter System Query Option ($filter) in GET_ENTITY

×

Subscribe to Web Service Testing A Blackjack Gui And Api

Get updates delivered right to your inbox!

Thank you for your subscription

×