Can I safely delete the active row while looping over an internal table?
As an example, consider this code:
LOOP AT lt_itab INTO ls_wa.
IF [...] . " A check that can't be done inside a 'DELETE lt_itab WHERE'
DELETE lt_itab INDEX sy-tabix
" OR
DELETE lt_itab FROM ls_wa.
ENDIF.
ENDLOOP.
Is it safe to delete records like this or will this logic not behave as intended?
Should I instead store the unique identifier for the rows in a temporary itab and run a DELETE lt_itab WHERE
after the loop?
I assume that delete operations on records other than the one that is loaded in the current iteration will definitely cause issues but I'm unsure if this is a valid, let alone good practice.
DELETE ... WHERE
is not an option and no other logic is included in the loop? – Pigweed