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

Distinct values from Itab

Former Member
0 Likes
673

How to obtain distinct values in internal tables like the

"SELECT DISTINCT" in Database tables?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
577

Hi Pooja,

Two ways to do this :

1. You can sort the internal table by the fields you want and then delete the adjacent duplicates comparing those fields by which you sorted.

sort <internal table> by field1> <field2>.

Delete adjacent duplicate values from itab comparing <field1> <field2>.

2. If you need to consider all fields of the internal table,

sort itab

Delete adjacent duplicate values from itab comparing all fields.

BR,

Preema

*Reward points for helpful answers

How to obtain distinct values in internal tables like the

"SELECT DISTINCT" in Database tables?

4 REPLIES 4
Read only

dani_mn
Active Contributor
0 Likes
577

HI,

you can use DELETE ADJACENT to delete duplicates and the remaining will be distinct values.

SORT itab by field.

DELETE ADJACENT-DUPLICATES FROM ITAB.

Regards,

Read only

Former Member
0 Likes
577

HI,

1>sort itab by <field>.

2>delete adjacent duplicates from itab comparing <field>.

Read only

Former Member
0 Likes
578

Hi Pooja,

Two ways to do this :

1. You can sort the internal table by the fields you want and then delete the adjacent duplicates comparing those fields by which you sorted.

sort <internal table> by field1> <field2>.

Delete adjacent duplicate values from itab comparing <field1> <field2>.

2. If you need to consider all fields of the internal table,

sort itab

Delete adjacent duplicate values from itab comparing all fields.

BR,

Preema

*Reward points for helpful answers

Read only

Former Member
0 Likes
577

Hi all,

Thanks for all your answers. I am getting an error while rewarding points. I will try again later.

Regards,

Pooja