cancel
Showing results for 
Search instead for 
Did you mean: 

CDS table function - SELECT TOP 1

Former Member
0 Kudos
13,640

Hello gurus,

I have a requirement to do join in CDS view and I need only first found row from the right table for every record from the left table. As I searched through forum here, I had found I need to use CDS table function and implement SQL script in my method. However, it does not work as planned.

Here is simple example:

Imagine I have EKKO (purchase order header) table. For each purchasing document (EKKO-EBELN) I want to find first found material from EKPO (purchasing document items - EKPO-MATNR).

1) I have created table function:

2) I have created AMDP class implementation:

3) I use my table function in CDS view:

4) The result looks like this:

The result I want is first matnr for each document.

Any help would be highly appreciated.

Thank you.

Lukas

View Entire Topic
former_member284740
Participant

You could try it with simple select in your ABAP (so no CDS)

SELECT ... UP TO 1 ROWS 

and don't forget ORDER BY PRIMARY KEY
Former Member
0 Kudos

Hi Guus,

sorry, it won't help me. I need to use CDS.

Regards,

Lukas