query options in function to database query
source link: https://answers.sap.com/questions/13892327/query-options-in-function-to-database-query.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
query options in function to database query
Hello all,
I have defined a function that supports a filter. So far I access the filter parameters using req._queryOptions and build the select accordingly. My problem is that an additional requirement would now make this too complex.
function getNearbyPoints(latitude : Decimal, longitude : Decimal) returns array of Records;
How can I pass the query options from the request directly into the query of the database?
I did find a topic on this here in SCN, but it is older and there was no answer.
Thanks a lot
Cab you provide more details as to what you have in mind regarding query options? Is it just straight key value combinations or additional functionality such as filters, field selections etc?
Something like this?
http://localhost:4004/community-example/getNearbyPoints(latitude=1232.23,longitude=212.23)?Test=12¶2=13&$filter=description eq 'example record'
And then what do you want to do with the query options on the database?
Hi Martin Stenzig ,
Exactly, it's about $select and $filter.
Based on the coordinates, points in the surroundings are determined (with a spatial function). At the moment all are returned and filtered by type, here I look into $filter myself and build the condition. Now more fields will be added, which makes it more complex to build. My thought was, if a standard entity can do all this itself, there must be a possible way to do it.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK