<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Delete Internal table in same loop- Can we do this? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358144#M1233530</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Praveen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the best way to do is jus by &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ITAB where (some key ) = WA_ITAB-key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;since itab and wa_itab has a key field this should work.  Test it and telme in case you need any help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@ Chintan,&lt;/P&gt;&lt;P&gt;Your statement will work only if the table contains a header line.  If it is without header line the statement wont work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gowri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Apr 2009 10:24:44 GMT</pubDate>
    <dc:creator>former_member873340</dc:creator>
    <dc:date>2009-04-07T10:24:44Z</dc:date>
    <item>
      <title>Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358134#M1233520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT ITAB INTO WA_ITAB.

read table itab2 into wa_itab2.

if sy-subrc is initial.

*I want to delete entries from ITAB.*

DELETE ITAB FROM WA_ITAB.
MODIFY ITAB.

endif.



ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am getting a dump if i do like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the correct syntax for this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;Praveen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: PRAVEEN s on Apr 6, 2009 11:19 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2009 21:17:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358134#M1233520</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-06T21:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358135#M1233521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT ITAB INTO WA_ITAB.
v_tabix = sy-tabix.  "&amp;lt;&amp;lt;&amp;lt;
read table itab2 into wa_itab2.
 
if sy-subrc is initial.
DELETE ITAB FROM WA_ITAB index v_tabix.  "&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;.
MODIFY ITAB.     " &amp;lt;&amp;lt;&amp;lt;&amp;lt; After deleting why need a modify ???
endif.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a®&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2009 21:23:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358135#M1233521</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2009-04-06T21:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358136#M1233522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not a good idea to delete records from a table that you are looping through. SY-TABIX would be hard to interpret.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having said that, we quite often delete the particular line that we are on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Apr 6, 2009 5:32 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2009 21:24:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358136#M1233522</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-06T21:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358137#M1233523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am getting an error message &lt;/P&gt;&lt;P&gt;on &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DELETE ITAB FROM WA_ITAB index v_tabix&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA_ITAB May not be converted into a number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob I have a situation to use this logic..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rgds&lt;/P&gt;&lt;P&gt;praveen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2009 21:50:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358137#M1233523</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-06T21:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358138#M1233524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;change your statement like below specified&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ITAB index v_tabix&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Peranandam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 00:06:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358138#M1233524</guid>
      <dc:creator>Peranandam</dc:creator>
      <dc:date>2009-04-07T00:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358139#M1233525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Praveen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change line DELETE ITAB FROM WA_ITAB index v_tabix.&lt;/P&gt;&lt;P&gt;To              DELETE TABLE ITAB FROM WA_ITAB.   &amp;lt;----&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;Use keyword 'TABLE'.&lt;/P&gt;&lt;P&gt;Since 'itab' is internal table not database table. &lt;/P&gt;&lt;P&gt;That is why you are getting error 'WA_ITAB May not be converted into a number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Sap Fan on Apr 7, 2009 7:19 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 04:58:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358139#M1233525</guid>
      <dc:creator>awin_prabhu</dc:creator>
      <dc:date>2009-04-07T04:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358140#M1233526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Praveen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here in this problem , according to sytax we cant specify work area and index same time.&lt;/P&gt;&lt;P&gt;so change your staemt to DELETE itab INDEX idx. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;because we are specifying index so there is no need to give work area.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nitin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 05:07:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358140#M1233526</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T05:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358141#M1233527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;    You can do that, but with little modification&lt;/P&gt;&lt;P&gt;    Don't use DELETE statement in LOOP and ENDLOOP statement, instead set a flag if the condition is met.&lt;/P&gt;&lt;P&gt;Note:- If we use DELETEstatement in LOOP,  every time the statement is executed, it has to regenerate the index, which will effect the performance if the records are more in the internal table.&lt;/P&gt;&lt;P&gt;    Then with DELETE statement delete all the records with the flag is set outside the LOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;see the sample code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
'You have not used any where condition in READ statement, so not clear that how you are comparaing itab and itab2
"Declare a field flag of  type c in itab internal table.


LOOP AT itab INTO wa_itab.
  w_tabx = sy-tabix.
  READ TABLE itab2 INTO wa_itab2 WITH KEY field = wa_itab-field.
  IF sy-subrc = 0.
    wa_itab-flag = 'X'.
    MODIFY itab INDEX w_tabx FROM wa_itab TRANSPORTING flag.
  ENDIF.
  CLEAR w_tabx.
ENDLOOP.
     
DELETE itab WHERE flag = 'X'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bala Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 05:24:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358141#M1233527</guid>
      <dc:creator>former_member585060</dc:creator>
      <dc:date>2009-04-07T05:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358142#M1233528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Simply write down &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when u have written ur delete statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 06:06:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358142#M1233528</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T06:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358143#M1233529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Simple write down&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DELETE ITAB.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;in place of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;DELETE ITAB FROM WA_ITAB.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;MODIFY ITAB.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chintan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 06:10:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358143#M1233529</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T06:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358144#M1233530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Praveen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the best way to do is jus by &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ITAB where (some key ) = WA_ITAB-key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;since itab and wa_itab has a key field this should work.  Test it and telme in case you need any help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@ Chintan,&lt;/P&gt;&lt;P&gt;Your statement will work only if the table contains a header line.  If it is without header line the statement wont work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gowri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 10:24:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358144#M1233530</guid>
      <dc:creator>former_member873340</dc:creator>
      <dc:date>2009-04-07T10:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358145#M1233531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all.&lt;/P&gt;&lt;P&gt;As I am having issues with this delete statement with Work area.I moved it to different internal table &lt;/P&gt;&lt;P&gt;and resolved issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rgds&lt;/P&gt;&lt;P&gt;Praveen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2009 16:46:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358145#M1233531</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-07T16:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Internal table in same loop- Can we do this?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358146#M1233532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;do like that&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;DATA&lt;/SPAN&gt;: v_tabix &lt;SPAN style="color: #0000ff;"&gt;TYPE&lt;/SPAN&gt; i.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;LOOP AT&lt;/SPAN&gt; itab &lt;SPAN style="color: #0000ff;"&gt;INTO&lt;/SPAN&gt; wa_itab.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;ADD&lt;/SPAN&gt; &lt;SPAN style="color: #00ccff;"&gt;1&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;TO&lt;/SPAN&gt; v_tabix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;READ TABLE&lt;/SPAN&gt; itab2 &lt;SPAN style="color: #0000ff;"&gt;INTO&lt;/SPAN&gt; wa_itab2.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt; IF&lt;/SPAN&gt; sy-subrc &lt;SPAN style="color: #0000ff;"&gt;IS INITIAL&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt; DELETE&lt;/SPAN&gt; itab &lt;SPAN style="color: #0000ff;"&gt;INDEX&lt;/SPAN&gt; v_tabix.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt; SUBTRACT&lt;/SPAN&gt; 1 &lt;SPAN style="color: #0000ff;"&gt;FROM&lt;/SPAN&gt; v_tabix.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt; ENDIF&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;ENDLOOP&lt;/SPAN&gt;.&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jul 2014 20:22:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-internal-table-in-same-loop-can-we-do-this/m-p/5358146#M1233532</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-07-11T20:22:54Z</dc:date>
    </item>
  </channel>
</rss>

