Skip to Content
Technical Articles
Author's profile photo Sreenu Reddy Yarramachu

MultiInput Functionality By Using Filters in OData

In the front end/SAPUI5 application we have a multi-input field, the user to enter multiple values. We need to fetch the data based on user-provided inputs.

We cant do this by using a read statement as we are getting multiple values. By using filters we can display the entire data, for single/multiple values or ranges as well.

Please follow the below procedure to display the data for the multi-input.

Go to SEGW T-Code and create a new Project.

Create an Entity.

Add properties.

Redefine the method “MULTIINPUTSET_GET_ENTITYSET” .

  METHOD multiinputset_get_entityset.
*** --- Data Declarations
    DATA:lr_serial TYPE RANGE OF z_si.
**-- Read the filter values filled from URL based on the user search
    LOOP AT it_filter_select_options INTO DATA(ls_filter).
      CASE ls_filter-property .
*** - -Serial Number
        WHEN 'SerialNumber'.
          LOOP AT ls_filter-select_options INTO DATA(ls_fil).
            APPEND INITIAL LINE TO  lr_serial
            ASSIGNING FIELD-SYMBOL(<fs_serial>).
** -- Serial Number to upper case
            <fs_serial>-low     =  to_upper( ls_fil-low ).
            <fs_serial>-option  =  ls_fil-option.
            <fs_serial>-sign    =  ls_fil-sign.
          ENDLOOP.
      ENDCASE.
    ENDLOOP.
*** --- Get Details
    SELECT ebeln ebelp ham_id
           txz01 serial asset_tag
           status mfctr_name model_name
           deplymt_type asset_type
      FROM zham_details
      INTO TABLE et_entityset
      WHERE serial IN lr_serial.
    IF sy-subrc EQ 0.
** -- Inline Count
      es_response_context-inlinecount = lines( et_entityset ).
** -- Paging
      CALL METHOD /iwbep/cl_mgw_data_util=>paging
        EXPORTING
          is_paging = is_paging
        CHANGING
          ct_data   = et_entityset.
    ELSE.
*** --- Error Message
      RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
        EXPORTING
          textid  = /iwbep/cx_mgw_busi_exception=>business_error
          message = lc_serial.
    ENDIF.
  ENDMETHOD.

Maintain and Register the service.

Output:

URI:

http://**:**/sap/opu/odata/sap/ZODATA_FILTER_SRV/MultiInputSet?$filter=(SerialNumber eq ‘EQW78053’ or SerialNumber eq ‘C02R86UUG8WP’ or SerialNumber eq ‘GCY6HC2’) &$format=json

Thanks for reading.

 

 

 

 

 

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo JOEL SANCHEZ LARA
      JOEL SANCHEZ LARA

      Hi Sreenu,
      Nice blog! but it is not clear to me how I associate the odata with the miltiimput? what should i do next?

      Tnks!