cancel
Showing results for 
Search instead for 
Did you mean: 

Sort oder of CDS-View

Former Member
32,364

Hi Experts,

I don;t understand how can I maintain the sort order of CDS view? For example I want to create cds view of table SPFLI and sort it by connnid. How can I do this. I use statement

DEFINE VIEW Z_spfli_view AS SELECT FROM spfli {

     connid as number,

}

And after that I can;t use ORDER BY. So how can I sort the result list? Maybe some annotations can be used?

Best Regards,

Mikhail

View Entire Topic
pfefferf
Active Contributor

Hello,

for a HANA CDS View you can use "order by". For an ABAP CDS View no "order by" is possible. You have to to the sort when you consume the view in e.g. an Open SQL Statement.

Regards,

Florian

Former Member
0 Kudos

ok, so, I have no possibility to sort it without starting ABAP Report? I just want to create smart template fiori application. For this I created a CDS view, then generated ODATA service. Is it possible maybe to create some 'consumption' view and use some analytical annotations? I need to sort it without coding. Or it is absolutely impossible?

pfefferf
Active Contributor
0 Kudos

There exists no annoation to define a kind of "default sort" (UI Annotations - Reference - SAP Library). On the backend side it would also make no sense to define a hard sort criterion because from the client side different sort criteria may be used (specific to the requirements).

On the client side you could add a default sort criterion during start up which is then applied as filter to the binding of the OData service.

Herbert_Stoe
Newcomer
0 Kudos
.... so SAP learned that order by might be useful - in thinking that the database should handle the performance load (if possible) and not the application server, I got the impression that ABAP CDS is implemented improperly considering sorting..