cancel
Showing results for 
Search instead for 
Did you mean: 

query for fetching multiple input values for the same field

Former Member
0 Kudos

Hi,

i am trying to do a query operation for fetching data for a single filed with multiple inputs.

for eg:

below query , i will be able to fetch data for input field Number is equal to 2

http://usphik2d.us.kellogg.com:8000/sap/opu/odata/SAP/Z_POC_SRV/samplesalesmultiple1Set?$filter=Numb... eq '2'

i would like to fetch the values for input field Number is equal to 2 and 3 also..

-Madhav

Accepted Solutions (0)

Answers (1)

Answers (1)

sreehari_vpillai
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi Sreehari,

i did tested as you suggested, i am getting the output for only first value , below is the query i used

http://usphik2d.us.kellogg.com:8000/sap/opu/odata/SAP/Z_POC_SRV/samplesalesmultiple1Set?$filter= (Number eq '0000000002' or Number eq '0000000001')

i am getting the output only for value 0000000002

-Madhav

sreehari_vpillai
Active Contributor
0 Kudos

Did you debug the GET_ENTITYSET method for the service ? make sure if you are receiving both the filters values ( 0000002 and 000001 ) in IT_SELECT_OPTIONS . If yes, check if the data is fetched or not.

Sree

Former Member
0 Kudos

Hi Sreehari,

i am actually Novice to Gateway, could you please tell me where to check GET_ENTITYSET method?

and where to check IT_SELECT_OPTIONS?

-Madhav

former_member184739
Contributor
0 Kudos

Hi Madhav,

Please check below blogs for end-end implementation.

http://scn.sap.com/community/gateway/blog/2013/06/18/to-code-or-not-to-code

http://scn.sap.com/docs/DOC-43000

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0efbaca-45ba-3010-b7bb-8c1c5aa10...

Code to get filters :

*-get filter

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

*-get filter for ProductID

  READ TABLE lt_filters WITH TABLE KEY property = 'PRODUCT_ID' INTO ls_filter.

  IF sy-subrc EQ 0.

    LOOP AT ls_filter-select_options INTO ls_so.

      MOVE-CORRESPONDING ls_so TO ls_product_id.

      INSERT ls_product_id INTO TABLE lt_product_id.

    ENDLOOP.

  ENDIF.

Regards

Prabaharan Asokan

sreehari_vpillai
Active Contributor
0 Kudos

Madhav,

If you are from a consumer side of odata service ( being a web developer ) , then ask the odata developer to implement full featured filter for the field you want .

-->where to find the get entity set method

     Go to the _DPC class, where you can find the *_GET_ENTITYSET method. Check the signature of the method in run time. Remember , what ever the record you are returning from teh method will be coming into your odata output.

Let me guess the method name : samplesalesmultiple1setget_entityset

Sree

Former Member
0 Kudos

hi sreehari,

i have done some investigation with help of Abaper and found that program is taking both the values in single structure and when returning also, output values are overlapping  according to the ABAP code mentioned in get entity set.

any suggestions here to handle this?

-Madhav

sreehari_vpillai
Active Contributor
0 Kudos

There is an importing parameter "IT_FILTER_SELECT_OPTIONS" in your get entity method . In debug mode, open this table, and tehre you will get a select option table with a structure "/IWBEP/T_COD_SELECT_OPTIONS" . You need to create a range variable ( LT_NUMBER tyep range of <DATATYPE> )

Load the range variable, and then use IN operator while selecting data from target table .

I remember some ABAP still

Sree

EkanshCapgemini
Active Contributor
0 Kudos

Hi Madhav,

Sreehari's statement in simpler words:

your backend RFC that you are calling for getting the data, should have a range table as input so that it is capable of receiving multiple inputs in range. Then in the where clause of select query, you need to take comaprison operator as 'IN' instead of EQ. Then if you map that range as input filter in your get_entityset, it will take multiple filters as well as return data for those filters.

Regards,
Ekansh