Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

TOP N Rows in ABAP CDS

former_member185181
Active Contributor

Hi,

Can someone help me to select TOP N rows in ABAP CDS select statement. I tried LIMIT and TOP but doesnt work.

1 ACCEPTED SOLUTION

arshad_ansary2
Active Participant

Hi Theerthan,

TOP and LIMIT statements are not supported in ABAP CDS views. You could alternatively use CDS Table Function(which calls a Abap ManagedProcedure function ) where these statements are supported .However you should make sure that your DB is HANA..

CDS Table Functions

BR

Arshad

6 REPLIES 6

arshad_ansary2
Active Participant

Hi Theerthan,

TOP and LIMIT statements are not supported in ABAP CDS views. You could alternatively use CDS Table Function(which calls a Abap ManagedProcedure function ) where these statements are supported .However you should make sure that your DB is HANA..

CDS Table Functions

BR

Arshad

Doesn't it seem awful that your brand-new CDS promoted as hell, doesn't support such simple thing?

Good old OpenSQL supports this from early releases, I do not understand the profit of CDS.

dezmond06

I couldn't agree more. 2 years later and I am here looking for the same solution and there still seems to be nothing. There are some workarounds using table functions but it is just embarrassing that there is no "select single" or "select up to n rows" within ABAP CDS.

I am busy trying to refine a piece of work that has taken us months. It returns multiple records for a material one for each barcode. I only need one record for one barcode, the first one. But it can't be done. All the work is in a heirarchy of CDS Views so I cannot use the open SQL call in my program to implement the restriction. I feel like SAP said: "Trust us, do it all in CDS" and now after months of work they're going to say: "Yeah, everything... well except for that one basic requirement that everyone will need at some point." It is really frustrating.

dmitry_kuznetsov1
Active Participant

Have to say this is an enormous amount of work just because we're missing "select single" or "select up to 5 rows".

merveguel
Participant
0 Kudos

If you are using table control, then I would suggest you to use 'growing' properties (growing, growingThreshold etc.).