Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9091

Re: Filtering OData Model data at client side (SAP UI5 program)

$
0
0

I think I am just a step away in achieving it.

 

 

 

As you said, below is the what I implemented in get_entitySet() method.

 

 

 

---------------------------------

 

 

DATA: lt_filters          TYPE  /iwbep/t_mgw_select_option,

      ls_filter           TYPE  /iwbep/s_mgw_select_option,

      ls_so               TYPE  /iwbep/s_cod_select_option,

      my_filter_string    TYPE  string,

      lt_userinfo         TYPE table of zuser_info,

      ls_userinfo         like line of lt_userinfo,

      ls_entity           LIKE LINE OF    et_entityset,

 

 

      str                 TYPE string.

 

 

 

lt_filters = io_tech_request_context->get_filter( )->get_filter_select_options( ).

 

my_filter_string  = io_tech_request_context->get_filter( )->get_filter_string( ).

 

 

 

str = my_filter_string+9(12).

 

REPLACE ALL OCCURRENCES OF '=' IN str WITH ''.

 

 

 

SELECT single * FROM zuser_info INTO ls_userinfo WHERE Zuserid = str.

 

 

 

    if sy-subrc = 0.

          ls_entity-zuserid    = ls_userinfo-Zuserid.

          ls_entity-Zaddr = ls_userinfo-Zaddr.

          ls_entity-Zcountry  = ls_userinfo-Zcountry.

          APPEND ls_entity TO et_entityset.

 

 

    else.

            SELECT * FROM zuser_info INTO table et_entityset.

 

 

    endif.

 

------------

 

 

However I am not getting expected result. sy-subrc value is not 0 meaning the query is not retrieving any rows so it is going to else part. What I found in debugging is

 

 

'my_filter_string' value is coming as : ( ZUSERID = '123098' ).

 

 

 

I did not know how to get the value from this string...so I substring so that I can get only the digit part. Below is the code.

 

 

 

str = my_filter_string+9(12).

REPLACE ALL OCCURRENCES OF '=' IN str WITH ''.

 

 

 

Now if I see in the debug the value of str is : '123098'.

 

 

 

But the query "SELECT single * FROM zuser_info INTO ls_userinfo WHERE Zuserid = str." is not retrieving any rows.

 

 

 

Whereas, if I hard code the condition in the query as below then it works..

 

 

 

SELECT single * FROM zuser_info INTO ls_userinfo WHERE Zuserid = '123098'.

 

 

 

May be I am doing a very silly mistake but since I am from java/portal developer so finding it tough with ABAP programming. Thanks in advance.


Viewing all articles
Browse latest Browse all 9091

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>