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: 
Read only

ABAP CDS select distinct values

former_member192842
Participant
0 Likes
33,370

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
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
16,988

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
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
16,989

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.

Read only

0 Likes
16,988

we can use open SQL 'LIMIT' right?

Read only

Former Member
16,988

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