SAP Knowledge Base Article - Public

2726463 - Fields Not Sorted Using $OrderBy in OData Reports

Symptom

You have built an OData query to retrieve report data, and you have used the operand OrderBy to sort the fields, however in the report results you can see that the data is not sorted.

For example: You are calling the report Invoice Volume via the following URL:

https://myxxxxxx.sapbydesign.com/sap/byd/odata/ana_businessanalytics_analytics.svc/RPCRMCIVIB_Q0001QueryResults?$select=CIPR_PROD_UUID,CIACBA_PRJ_UUID&$orderby=CDOC_UUID desc

And you would expect that the results are sorted by Invoice ID, in a descending order, however this is not the case.

Environment

SAP Business ByDesign

SAP Hybris Cloud for Customer

Cause

For the OrderBy option to work, you have to add the field on which you are sorting to the view (via $select) and it has to be the first field in the list.

Resolution

In this example, you would need to change the URL to:

https://myxxxxxx.sapbydesign.com/sap/byd/odata/ana_businessanalytics_analytics.svc/RPCRMCIVIB_Q0001QueryResults?$select=CDOC_UUID,CIPR_PROD_UUID,CIACBA_PRJ_UUID&$orderby=CDOC_UUID desc

See Also

1628310 - Sorting of Characteristics and Key Figures in Reports

Keywords

Odata, report, orderby, sorting, characteristic, ascending, descending, System query options '$orderby' are not allowed in the requested URI , KBA , AP-RC-ANA , C4C, ByD, Travel: Analytics Tools & Frameworks , Problem

Product

SAP Business ByDesign all versions ; SAP Cloud for Customer core applications all versions