Finding duplicates in ABAP internal table via grouping
We all know these excellent ABAP statements which allows finding unique values in one-liner: it_unique = VALUE #( FOR GROUPS value OF <line> IN it_itab GROUP BY <line>-field WITHOUT MEMBERS ( value ) ). But what about extracting duplicates? Can one utilize GROUP BY syntax for that task or, maybe, table comprehensions are more useful here? The only (though not very elegant) way I found is: LOOP AT lt_marc ASSIGNING FIELD-SYMBOL(<fs_marc>) GROUP BY ( matnr = <fs_marc>-matnr werks = <fs_marc>-werks ) ASSIGNING FIELD-SYMBOL(<group>). members = VALUE #( FOR m IN GROUP <group> ( m ) ). IF lines(