SAP Builders Discussions
Join the discussion -- ask questions and discuss how you and fellow SAP Builders are using SAP Build, SAP Build Apps, SAP Build Process Automation, and SAP Build Work Zone.
cancel
Showing results for 
Search instead for 
Did you mean: 

OData Filtering in SAP Build Apps – Could This Work For You?

Dan_Wroblewski
Developer Advocate
Developer Advocate

People always want full OData filtering (and other OData manipulations) in SAP Build Apps. But the filtering is severely limited for most people (see this recent question).

The Potential Solution

Currently, there is no way to do a lot of the filtering OData provides, like Contains or Ends With and things like that.

To "solve" this, I used the REST data resource with destinations, instead of the OData integration. I admit you lose a lot of the advantages of the OData data resource – interpretation of the metadata, selecting all the entities, filtering/paging/ordering, and even converting the response. All that has to be done manually.

Still, I was able to filter and I thought perhaps it might help someone. Here's what I did.


I created a data resource of type "SAP BTP destination REST API integration" using a destination to the Northwind OData service.

dan_wroblewski_0-1687416847521.png

I enabled the list action, and set it's path to a formula.

query.search.query

dan_wroblewski_3-1687416052032.png

I then created a data variable (collection of records), and in the logic of the data variable, set the Get record collection's Search parameter.

dan_wroblewski_4-1687416113593.png

Inside there is just query field, and I set this to the entity I wanted plus any filtering, such as:

/Customers?$filter=contains(CustomerID, 'AL')

dan_wroblewski_5-1687416159655.png

The only other thing I had to do is, when setting the data variable from the output, I used a formula to remove the OData header:

outputs["Get record collection"].records.value

Because the OData response adds a header and my REST data resource does not handle this.

2023-07-17_08-52-53.png

And it seemed to work:

dan_wroblewski_6-1687416184851.png

 

My Challenge to You

OK, this is just something I threw together in response to a question in the community. But:

  • Is it helpful to anyone?
  • Can you improve on it?
  • Are there fatal limitations to it?
  • Is there a better solution?

Leave your comments below.




--------------
See all my blogs and connect with me on Twitter / LinkedIn
6 REPLIES 6

Ben_Samuel
Explorer
0 Kudos

Hi Dan

i have BTP Build Apps trail account and managed to connect with ease to my sap backend.

but i could find the screen where you registe the list for extending the search. can you guide me and what did i miss?

regards

0 Kudos

Glad you could get part of the way.

What do you mean "the screen where you register the list for extending the search"?

  • I went to the Data tab (top navigation), where I created a data resource. Dan_Wroblewski_0-1712206050478.png

     

  • This gives me the screen I showed in the post above.



--------------
See all my blogs and connect with me on Twitter / LinkedIn

0 Kudos

Thanks - I got the screen now. 

this is very helpful one for me

shivam123ortan
Participant
0 Kudos

It was very informative Dan,
I had some problem in accessing the below OData

shivam123ortan_0-1712690014071.png

as using this in Record Collection only provides me 'current.id' 

outputs["Get record collection"].records.value

shivam123ortan_1-1712690162101.png

please provide a solution

 

 

0 Kudos

Sorry to have missed this reply.

SAP Build Apps sometimes does not know the schema of the response, so it will not provide you with autocomplete of the fields. The way around this is to use a formula, where you can specify anything you want. Note you might get a warning in red saying it doesn't recognize the field, but you can still use it.

SAP Build Apps can recognize the schema if you run a test in the data resource (Data tab) and then click SET SCHEMA FROM RESPONSE. 




--------------
See all my blogs and connect with me on Twitter / LinkedIn

Ben_Samuel
Explorer

hi Dan

i have the same situation where i have to implement all the steps you listed out.

it woks like magic.

thanks for your post.  it is very helpful.