OData Service Definitions - ordering tables in .xsodata file - odata

I'm new in SAP HANA and I'm trying to sort a table in .xsodata file. Is that possible?
Best regards.

There's no option to specify the sorting order in the odata service definition.
Usually, the ODATA client specifies the expected order via the $orderby URL parameter.

Related

SAP OData Service Filter is not filtering

I'm learning to get delta data from SAP Fiori sample gateway to Azure SQL by using Azure Data Factory and filter feature on OData service.
I'm using OData Service that exposed by Fiori sample, and one of the table sample is PurchaseOrders.
I tried like this:
$filter=ChangedAt ge datetime '2020-09-08T22:00:00'
But it is still return all the records.
I found sap:filterable is false at metadata
Is that filterable false is made me cannot filter this?
Is there any other way to do delta extraction on OData rather than using filter?
Thank You
As #Boghyon wrote above the "sap:filterable" is just an Annotation, which can help to build the UI. You have to check the DPC_EXT class's GET_ENTITY_SET method of the entity type that you try to filter. If filtering isn't implemented then (1.) in case of standard service you're more or less stuck (it cannot be filtered for a reason) (2.) in case of custom service you can implement filtering

ADF - Odata - How to perform an optional select

I've created an ADF flow that loops over URL's to fetch OData using the OData connection.
However, not all fields are available in all URL's, there are certain ones that are available in one URL, but not in the other. A $Select is used to select the fields that we need.
Is it possible to have an optional selection (as in, if the path is not available, do not fetch this field and return null instead for instance)? Would help us a great deal.
I've tried adding ? after the field, but that does not work. $select=Field1,Field2,FieldOptional?
Thanks
As I understand you are trying to loop through a bunch of a URL and the query on the ODATA URL will change and so will be the fields . I think you can use a lookup where you pass the unique url and its gives the fields and then concatenate the url with the fields and make a odata call .

Does odata support to get entities by multiple ids?

Generally I want some equivalent of:
select * from my_entity where id IN (1,2,3)
In odata it should be like that:
GET http://my-host.com/Api/V4/MyEntity(1,2)
But for API which I try to use the upper url does not work :( So does odata API supports get entities by multiple ids? If yes - what url pattern to use?

OData Delete with Filter

I have the problem that our backend uses an OData-"like"-Processor which has some special functions. It is oriented at OData_2.0
So the question will be:
What is the most OData like approach for this kind of the following requests
Our backend Data-Model has no single-attribute-keys. But it's recommended to be OData-Like if possible.
First: I need to delete several objects via one OData Request. My first idea is to use filters to define which objects should be deleted. But I', not sure if this is the right approach.
For Example: I want to delete all Items which have a price greater than 10.00
http://.../<oDataServiceX>/Item?$filter=ItemPrice gt 10.00
Second: When I want to delete an object which is not identifiable by one single key-attribute. How can I define that in the classical OData-Delete-Request-Syntax.
Is the following OData-like?
http://.../<oDataServiceX>/Item(1,54,2) //3 Attributes which define the key for the Item
Or should I do a filter again? (If filter is a proper way of doing this).
http://.../<oDataServiceX>/Item?$filter=keyAttr1 eq 1 and keyAttr2 eq 54 and keyAttr 3 eq 2
You can't delete multiple entries in a single OData query, you need first to retrieve their keys and then send multiple delete requests. There are two ways to improve this process:
Use OData batch to send all delete request in a single HTTP call.
Use some of libraries that can simulate deletion using filter (internally they will issue multiple requests but for the application it will look like a single call). One of such libraries is Simple.OData.Client.
Hope this helps.
Odata v4 supports the format DELETE /entity(key1='', key2='') and so on.
However, for oData v2, one option could be to use the request body to pass some data over. DELETE /entity, with data in the body.
The documentation states that the convention is to delete an entity by key. However, this was the approach followed when we had to delete by multiple keys for an odata v2 service. Also while implementing this using oData v2 libraries, we had to add a routing convention to support Delete without a key.

Change precision of RFC parameter in OData service builder?

I am using SAP function BAPI_TRADINGCONTRACT_GET_LIST in which there is property reqquality whose type is edm.decimal, precision is 13 and scale 3. I want to edit it, but can't do it. How can I change the scale value to 2?
Or how can I edit a property of the RFC module?
Or any other procedure to handle the properties?
This depends on whether the Odata model is a custom one or if you are using an existing SAP delivered one (in the SAP namespace).
If you are using a SAP standard one, I would check if SAP has provided a Business Add In (BADI) to enhance the metadata model and associated data provider - for common Odata models SAP provides extension capabilities, here I would just add a new field and set it to the precision you require.
If the above is not available you could create a new Odata Model (using transaction SEGW) and wrap the function as per this tutorial - http://scn.sap.com/people/volker.drees/blog/2012/10/26/step-by-step-guide-to-build-an-odata-service-based-on-rfcs-part-1
Good Luck..

Resources