on 05-12-2015 9:48 AM
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
i would like to fetch the values for input field Number is equal to 2 and 3 also..
-Madhav
http://usphik2d.us.kellogg.com:8000/sap/opu/odata/SAP/Z_POC_SRV/samplesalesmultiple1Set?$filter=(Num... eq '2' or Number eq '3')
You can do like this.. Check below help for samples
URI Conventions | OData - The Protocol for REST APIs
Sree
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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
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
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
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.