on 2016 Feb 05 10:50 AM
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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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.
You can use the KEY keyword in front of the fields in your view that you want to sort the view by. These fields must all be listed as the first fields in your view. You should also specify the
role of annotation AbapCatalog.preservekey: True at the top of your code. See Key definition in cds views for more details.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 10 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.