Code: Alles auswählen.
TYPES:
BEGIN OF ts_struct,
p TYPE i,
t TYPE i,
a TYPE i,
END OF ts_struct,
tt_table TYPE STANDARD TABLE OF ts_struct WITH KEY p t.
DATA:
ld_index TYPE i,
lt_source TYPE tt_table,
lt_result1 TYPE tt_table,
lt_result2 TYPE tt_table.
lt_source = VALUE #( ( p = 1 t = 1 a = 4 )
( p = 1 t = 1 a = 5 )
( p = 1 t = 2 a = 2 )
( p = 2 t = 1 a = 1 )
( p = 2 t = 1 a = 2 ) ).
LOOP AT lt_source ASSIGNING FIELD-SYMBOL(<ls_source>)
GROUP BY ( p = <ls_source>-p t = <ls_source>-t gs = GROUP SIZE ) ASSIGNING FIELD-SYMBOL(<ls_source_group>).
CLEAR ld_index.
LOOP AT GROUP <ls_source_group> ASSIGNING FIELD-SYMBOL(<ls_source_member>).
ADD 1 TO ld_index.
IF <ls_source_group>-gs EQ 1.
APPEND <ls_source_member> TO lt_result1.
APPEND <ls_source_member> TO lt_result2.
ELSEIF ld_index EQ 1.
APPEND <ls_source_member> TO lt_result1.
ELSEIF ld_index EQ 2.
APPEND <ls_source_member> TO lt_result2.
ENDIF.
ENDLOOP.
ENDLOOP.
Folgende Benutzer bedankten sich beim Autor IHe für den Beitrag (Insgesamt 2):
DeathAndPain • a-dead-trousers