cancel
Showing results for 
Search instead for 
Did you mean: 

Fetching text from API_PRODUCT_SRV - Filter/key not working in Abap cloud call

LaurensSteffers
Participant
0 Kudos
178

Hi all,

I hope you can help. We are currently calling an API from our s4hana public cloud stack (s4pc), uhm, within the same system. Reason is simple: not all cds views provide the correct functionality and with longtext.....well, you have to go to the api side.

We are able to determine the api path and actually call the api to fetch data, but somehow the filtering does not work correctly, in fact, the provisioning of a key doesn't work. 

To give you an idea of the code which actually works when we use the api.sap.com and tryout option:

/sap/opu/odata/sap/API_PRODUCT_SRV/A_ProductBasicText?$filter=Product eq '3'

this results in:

sap/opu/odata/sap/API_PRODUCT_SRV/A_ProductBasicText?$filter=Product%20eq%20%273%27

and that results in:

LaurensSteffers_0-1718377453616.png

Now, when we actually call this in abap cloud, the filter is not taken into account. The result is this no matter which filter we pass in the query (random examples of things I tried):

lo_request->set_query( query = '?$filter=(Product eq ''3'')&$format=json' ) (3 has like 4 single quotes)

?$filter=Product eq '3'

DATA(query) = |(Product='3',Language='EN')&$format=json|.

LaurensSteffers_1-1718377640583.png

So, we tried the different things we could find on tryout, documentation etc, but no application of the filter. 

It always returns the full set of available text without the filter being applied. I tried everything to copy the filter but no results.

The service url it determines based on the comm system/arrangement etc, is this. It does work otherwise we would not get any result.

LaurensSteffers_2-1718377843345.png

But the problem is that no matter what, the filter is not taken into account. 

In all honesty, I would rather pass the full key so it would look like this, but can't get it to work with the set_query. Any help in that area would be great! 

 

sap/opu/odata/sap/API_PRODUCT_SRV/A_ProductBasicText(Product='3',Language='EN')

We tried to contact (Product='3', Languate='EN') and pass this to the set_query, but that doesn't work. Replacing it using 'eq', doen't work.

Hope you have some ideas!

All the best

Laurens

 

 

Enda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi @LaurensSteffers

My understanding is when using the API API_PRODUCT_SRV directly or through an Application like POSTMAN the filtering works ok so it doesnt seem to be an issue with the API

 

Unfortunately i don't know how the API is called , howto reproduce internally in an S/4HANA CLoud System so i don't know why its not working - Sorry

 

Best Regards

Enda

LaurensSteffers
Participant
0 Kudos

Hi all,

Well, in the end we got it working but we decided to take this specific route: 

https://community.sap.com/t5/technology-blogs-by-sap/service-consumption-model-2-for-odata-client-pr...

It is the service consumption model. 

I used this in the past and somehow I never got a entityset in my list on the left when I used a specific API with some stock info. Later on I discovered that the functions weren't available to us. Tried another api with api_product_srv an there you go, all the entities we needed. Followed the guide and that was it, works perfectly.

Cheers!

Laurens

 

Accepted Solutions (0)

Answers (1)

Answers (1)

LaurensSteffers
Participant
0 Kudos

Hello Enda,

thanks for the reply. Well, in fact we are calling it through an application (eclipse in this case), but the filter just does not work. Would you be able to provide a contact who has done something like this before?

Kind regards and all the best

Laurens