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: 

SELECT DISCTINCT with SALV

Former Member
0 Kudos

Dear All,

I would like to have unique rows for each user in a table only. The table has 3 columns:

1) userid

2) date

3) lastname

Therefore I changed my SELECT statement from

SELECT *

INTO TABLE showtable

FROM anytable.

to

SELECT min( date ) lastname

INTO TABLE showtable

FROM anytable

GROUP BY lastname

SORT BY lastname.

The complete code goes

DATA: showtable TYPE TABLE OF anytable.

DATA: gr_table TYPE REF TO cl_salv_table.

DATA: gr_functions TYPE REF TO cl_salv_functions.

DATA: gr_sorts TYPE REF TO cl_salv_sorts.

DATA: gr_columns TYPE REF TO cl_salv_columns_table.

DATA: gr_column TYPE REF TO cl_salv_column_table.

*Implementation

START-OF-SELECTION.

SELECT min( date) lastname

INTO TABLE showtable

FROM anytable

GROUP BY lastname

SORT BY lastname.

TRY.

CALL METHOD cl_salv_table=>factory

IMPORTING r_salv_table = gr_table

CHANGING t_table = showtable.

CATCH cx_salv_msg.

ENDTRY.

gr_table->display( ).

Any hints are very much appreciated.

Best wishes

Andi

1 ACCEPTED SOLUTION

former_member320332
Contributor
0 Kudos

If you want to show only the distinct records in ALV o/p , you can use DELETE ADJACENT DUPLICATE command on the internal table you are passing to Factory method..

But before that sort ur internal table with USERID in your case ....

Thanx..

1 REPLY 1

former_member320332
Contributor
0 Kudos

If you want to show only the distinct records in ALV o/p , you can use DELETE ADJACENT DUPLICATE command on the internal table you are passing to Factory method..

But before that sort ur internal table with USERID in your case ....

Thanx..