Basics

Question: Hi ,

i need to delete entries in an internal table with following condtion,,

LOOP AT I_KNA1 INTO WA_KNA1.
IF WA_KNA1-NAME1+0(5) = 'KSMOX' AND WA_KNA1-KUNNR GT 599999.
DELETE I_COSP INDEX SY-TABIX.
ENDIF.
ENDLOOP.

but in OLD, SAP says donot delete internal table entries inside a loop,if u do so, loop can no longer work properly. i couldn't find reason , why it works so,,iam enclosing OLD help ,,
I tried to use,
DELETE INT_KNA1 WHERE NAME1 LIKE 'KSMOX%' AND KUNNR GT 599999.
But this LIKE operator is not allowed in DELETE statement.
through some light,
regards
-------------------------------------------------------------------------------------
OLD - Help
The loop may not contain any operations on entire internal tables that change the table. However, you should remember that even saving a global internal table with the LOCAL statement in a procedure is a change operation on the entire table, since it exchanges the table contents. When you call procedures within loops, you should therefore check that it does not change the entire internal table. If you change the table, the loop can no longer work properly.

If you insert or delete a table entry within a loop pass, it is taken into account in subsequent loop passes as follows:

If you insert a line after the current line, it will be processed in a subsequent loop pass.
If you delete a line after the current line, it will not be processed in a subsequent loop pass.
If you insert a line before or at the current line, the internal loop counter will be increased accordingly.
If you delete a line before or at the current line, the internal loop counter will be decreased accordingly.

Answer:
Hi ,

i need to delete entries in an internal table with following condtion,,

LOOP AT I_KNA1 INTO WA_KNA1.
IF WA_KNA1-NAME1+0(5) = 'KSMOX' AND WA_KNA1-KUNNR GT 599999.
DELETE I_COSP INDEX SY-TABIX.
ENDIF.
ENDLOOP.

but in OLD, SAP says donot delete internal table entries inside a loop,if u do so, loop can no longer work properly. i couldn't find reason , why it works so,,iam enclosing OLD help ,,
I tried to use,
DELETE INT_KNA1 WHERE NAME1 LIKE 'KSMOX%' AND KUNNR GT 599999.
But this LIKE operator is not allowed in DELETE statement.
through some light,
regards
-------------------------------------------------------------------------------------
OLD - Help
The loop may not contain any operations on entire internal tables that change the table. However, you should remember that even saving a global internal table with the LOCAL statement in a procedure is a change operation on the entire table, since it exchanges the table contents. When you call procedures within loops, you should therefore check that it does not change the entire internal table. If you change the table, the loop can no longer work properly.

If you insert or delete a table entry within a loop pass, it is taken into account in subsequent loop passes as follows:

If you insert a line after the current line, it will be processed in a subsequent loop pass.
If you delete a line after the current line, it will not be processed in a subsequent loop pass.
If you insert a line before or at the current line, the internal loop counter will be increased accordingly.
If you delete a line before or at the current line, the internal loop counter will be decreased accordingly.

I am a little bit confused - are you trying to delete i_cosp or i_kna?
as for the like statement - this is only for sql statements - check the cp operator or use offsets as you did in the if clause.
Christian
Copyright ?2007 - 2008 www.jt77.com