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: 

Delete the minimum value from group in an internal table

0 Kudos
1,205

Hi,

i want to delete the smallest values (NR) for the associated text (TEXT) from my internal table.

Let's say my internal table looks like that:

and that's what I want to have.

Does somebody has any idea?

Thanks!

1 ACCEPTED SOLUTION

Patrick_vN
Active Contributor
955

Haven't tried, but I'd think it should work.

SORT itab BY TEXT ASCENDING NR DESCENDING.
DELETE ADJACENT DUPLICATES FROM itab COMPARING text.
6 REPLIES 6

JamesG
Participant
0 Kudos
955

Is the data still accurate?

0 Kudos
955

yes, but thats some sample data

JamesG
Participant
955

the nr's data and text's data none of them are corresponding.

what's your delete rule?

your above say and your photo is none of them are corresponding.

matt
Active Contributor
955

It looks to me that you want to keep the highest number, not delete the lowest.
This will work, but it may not be the most efficient.

DATA itab TYPE STANDARD TABLE OF ty_of_itab_line WITH DEFAULT KEY.
...
SORT itab BY TEXT ASCENDING NR DESCENDING.
LOOP AT itab ASSIGNING FIELD-SYMBOL(<wa>).
  DATA output TYPE HASHED TABLE OF ty_of_itab_line WITH UNIQUE KEY TEXT.
  INSERT <wa> INTO TABLE output.
ENDLOOP.

Patrick_vN
Active Contributor
956

Haven't tried, but I'd think it should work.

SORT itab BY TEXT ASCENDING NR DESCENDING.
DELETE ADJACENT DUPLICATES FROM itab COMPARING text.

0 Kudos
955

Nice and simple.

Kind regards,

Mateusz