I have an OData-V4 Service and I want to output the root entity only if the expand from the expand meets certain conditions. Side note: I'm trying to implement this with the SAP Cloud SDK.
In this example, the root entity with the Product 123456 should only be displayed if /toProductSalesDelivery/toMaterialStatus.BlockedForSalesOrder != B. Is this possible?
I have the following structure:
{
"value" : [
{
"Product" : "123456",
"Assortment" : "DE12",
"Disabled" : false
"IsActiveEntity" : true,
"toProductSalesDelivery" : [
{
"Product" : "123456",
"ProductSalesOrg" : "1000",
"toMaterialStatus" : [
{
"BlockedForSalesOrder" : "B"
}
]
}
]
}
]
}
My first try was via $expand and $filter. the filter on the navigation property was fulfilled, but that was not what I wanted. Of course I don't want the root entity to be displayed either.... It's just filtering the MaterialStatus array.
Product?$select=Assortment,Product&$expand=toProductSalesDelivery($expand=toMaterialStatus($select=BlockedForSalesOrder;$filter=(BlockedForSalesOrder ne 'B')))&$filter=((Disabled eq false))
Two hours later and "reading" the docs, I have now the following query. Unfortunately the root entity is still displayed.
Assortment_Product?$filter=toProductSalesDelivery/any(d:d/toMaterialStatus/any(m:m/BlockedForSalesOrder eq 'B'))
&$expand=toProductSalesDelivery($expand=toMaterialStatus)
What am I doing wrong? Is it possible at all?
This has been fixed with version 4.22.0 of the SAP Cloud SDK. Nesting lambdas is now possible.