Symptom
When calling a GET request for an OData V4 API, the system queries inserted in the URL don't have any effect.
Using the API Customer Return (A2X, OData V4) as an example: when calling the URL <host>/sap/opu/odata4/sap/api_customerreturn/srvd_a2x/sap/customerreturn/0001/CustomerReturn?top=10&expand=_Item,_Partner,_Text, the queries top and expand don't have any effect: there are more results than specified on top (+10) and the sub-entities item, partner and text are not present in the response.
Environment
SAP S/4HANA Cloud Public Edition
Cause
The queries are not working due to the malformed syntax of the URL. In OData V4, system query options must be prefixed with a dollar sign ($).
By omitting the $, the SAP Gateway treats expand and top as custom query parameters rather than system commands, so it simply ignores them. So this explains why the main order data is received (the request succeeds) but without the sub-entities (the expansion logic is never triggered).
Resolution
Add the dollar sign ($) before the commands:
- <host>/sap/opu/odata4/sap/api_customerreturn/srvd_a2x/sap/customerreturn/0001/CustomerReturn?$top=50&$expand=_Item,_Partner,_Text
Note: to use the _PricingElement in the expand query, the sales document number must be specified.
See Also
Keywords
odata v4, _Item, _Partner, _PricingElement, _Text, navigation, association, customer return, api_customerreturn, SalesOrder, system query options, top, expand, filter, orderby, select, count , KBA , SD-SLS-API-2CL , API (Public Cloud) , Problem
SAP Knowledge Base Article - Public