Code: Alles auswählen.
DATA: lr_selections TYPE REF TO cl_salv_selections.
DATA: lt_rows TYPE salv_t_row.
DATA: ls_rows TYPE lvc_s_row.
lr_selections = gr_table->get_selections( ).
lt_rows = lr_selections->get_selected_rows( ).
DATA: lv_lines TYPE i.
lv_lines = lines( lt_rows ).
DATA: lv_zaehler TYPE i.
lv_zaehler = 1.
DO lv_lines TIMES.
READ TABLE lt_rows INTO ls_rows INDEX lv_zaehler.
READ TABLE gt_table INTO gs_table INDEX ls_rows-index.
* Delete from DB
DELETE FROM table
WHERE lifnr = gs_table-lifnr
AND linam = gs_table-linam
AND kunnr = gs_table-kunnr
AND kunam = gs_table-kunam.
* Delete from ALV-Grid
DELETE gt_table INDEX ls_rows-index.
lv_zaehler = lv_zaehler + 1.
ENDDO.
gr_table->refresh( ).
Code: Alles auswählen.
Hole Liste der markierten Zeilen
Sortiere Liste absteigend damit du von unten nach oben löscht
LOOP über Liste
lösche Tabellenzeile
ENDLOOP
Folgende Benutzer bedankten sich beim Autor black_adept für den Beitrag:
ManMan
Code: Alles auswählen.
DATA: i_tab TYPE STANDARD TABLE OF i,
i_wa TYPE i VALUE 1,
i1 TYPE i VALUE 1,
i2 TYPE i VALUE 3,
i3 TYPE i VALUE 7.
DO 7 TIMES.
APPEND i_wa TO i_tab.
i_wa = i_wa + 1.
ENDDO.
BREAK-POINT.
DO 3 TIMES.
DELETE i_tab INDEX i1.
i1 = i2.
i2 = i3.
ENDDO.
BREAK-POINT.