New ABAP syntax, VALUE FOR skip appending entry if it already exists

Hello experts,

In the following test scenario:

I have an internal table that contains unique entries and duplicated entries.

Lets say we cannot touch this table and cannot delete duplicates etc.

And lets say I wanted to use the new ABAP syntax to get ONLY the unique entries from that table – how can this happen?

What I am trying is:

r_unduplicated_values = VALUE #( FOR row_of_tab_with_duplicates IN tab_with_duplicates
                                                        ( CORRESPONDING #( row_of_tab_with_duplicates ) ) .

The closest thing I was able to do was:
r_unduplicated_values = VALUE #( FOR row_of_tab_with_duplicates IN tab_with_duplicates
                                                       ( COND #( WHEN NOT line_exists( r_unduplicated_values[ key = row_of_tab_with_duplicates-key ] )
THEN CORRESPONDING #( row_of_tab_with_duplicates ) ) ) ).

 

But unfortunately this will just append empty rows in the case that the line already exists in the table

What do I need to add to this syntax skeleton so that when a row has already been added like the one we are currently processing in the FOR loop it skips appending this row and continues with the other rows?

I know it is possible to just let it append the duplicates and then sort + delete duplicates but I wanted to do it all at once if possible with the new syntax.

 

Thank you!

Scroll to Top