Application Development and Automation 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: 

ABAP CDS select distinct values

former_member192842
Participant
0 Kudos
26,222

Hi Experts,

I need a help in ABAP CDS. The want to write a Join or association statment in ABAP CDS. Consider the below table A and B

I want output to be

The input for me is column 1(value 1).

In case of ABAP I could have written 2 select queries and then looped table A and could have read the table B to create final output.

But in case of ABAP CDS is there way to achieve it. Because If I write Join/Association in ABAP CDS with value 1, then my output could be two rows below which is not same as the output mentioned above

1 Fed Makati

1 Fed BGC

Regards Anand

1 ACCEPTED SOLUTION

retired_member
Product and Topic Expert
Product and Topic Expert
9,840

You want to restrict the result set of a CDS View to one line (an arbitrary or the first ?).

To my knowledge, CDS DDL does not offer this. But you can use UP TO 1 ROWS when accessing your view with Open SQL.

3 REPLIES 3

retired_member
Product and Topic Expert
Product and Topic Expert
9,841

You want to restrict the result set of a CDS View to one line (an arbitrary or the first ?).

To my knowledge, CDS DDL does not offer this. But you can use UP TO 1 ROWS when accessing your view with Open SQL.

0 Kudos
9,840

we can use open SQL 'LIMIT' right?

Former Member
9,840

Hi, there are two ways:

a) Using a table function cds accessing table A and B through open SQL;

b) Creating an inner join between table A and table B on a.column1 = b.column1 where a.column1 = '1' => output as you created before, then a.column1 , a.column2, max(b.column2) group by a.column1, a.column2