<?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 records within the loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287673#M1832573</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just would like to add another suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there are lot( LOTS &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ) of records in an internal table which is looped and deleted, then it will affect the performance( like rearrangement of internal record index etc ). I have faced this issue, the program was getting executed for a day because of delete in loop. I solved it by appending the required records to a new internal table if the condition was met. I am not sure if the below helps you. You can do a comparison based on start-end runtime and check it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data lt_beleg type sorted table of ty_beleg with non-unique key belnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort lt_rot by belnr.&lt;/P&gt;&lt;P&gt;LOOP AT lt_rot into lw_rot.&lt;/P&gt;&lt;P&gt;at new belnr.&lt;/P&gt;&lt;P&gt;&amp;nbsp; flag = 'X'.&lt;/P&gt;&lt;P&gt;&amp;nbsp; read table lt_beleg with key benlr = lw_rot-belnr transporting no fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp; if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flag = ' '.&lt;/P&gt;&lt;P&gt;&amp;nbsp; endif&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt;if flag = 'X'.&lt;/P&gt;&lt;P&gt;&amp;nbsp; append lw_rot to lt_t_rot.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 20 Apr 2014 09:49:40 GMT</pubDate>
    <dc:creator>kesavadas_thekkillath</dc:creator>
    <dc:date>2014-04-20T09:49:40Z</dc:date>
    <item>
      <title>DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287648#M1832548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just read some of the threads in SCN and all have prescribed to &lt;SPAN style="font-size: 10pt;"&gt;avoid DELETE statement inside the loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See me case below. I have two local tables lt_beleg and lt_rot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOOP AT lt_beleg into lw_beleg.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DELETE lt_rot where BELNR = lw_beleg-BELNR.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;END LOOP.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am deleting records from lt_rot based on the BELNR from lt_beleg. But my lt_rot contains possible records where BELNR = ' '. So I dont have any other option to delete the records within loop, such that i'll will have records with other than BELEG as well as empty BELNR in my lt_rot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't understand how it will affect the performance, as am deleting the records with exact condition within the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me to clear it, else is there any other way to handle the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Waiting for your valuable ideas&lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro_emoticon jive_emote jive_macro" src="https://community.sap.com/718/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;RAM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 05:41:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287648#M1832548</guid>
      <dc:creator>former_member197475</dc:creator>
      <dc:date>2014-04-18T05:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287649#M1832549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ramakrishnan.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I don't where you read about it, but using &lt;STRONG&gt;DELETE itab looping the same itab&lt;/STRONG&gt; is only not advisable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For instance,&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loop at itab where field = value.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete itab.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endloop.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Instead &lt;STRONG&gt;delete itab where field = value is the best way.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 06:11:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287649#M1832549</guid>
      <dc:creator>Arun_Prabhu_K</dc:creator>
      <dc:date>2014-04-18T06:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287650#M1832550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;K.Arun Prabhu wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;.., but using &lt;/SPAN&gt;&lt;STRONG style="font-size: 10pt;"&gt;DELETE itab looping the same itab&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt; is only not advisable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Not correct. While DELETE ... WHERE is preferred, there is absolutely nothing wrong with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOOP AT itab INTO wa.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; IF &lt;EM&gt;some complicated condition is met.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; DELETE itab.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; ENDIF.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ENDLOOP&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might find&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOOP AT itab ASSIGNING &amp;lt;record&amp;gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; IF &lt;EM&gt;some complicated condition is met.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; DELETE &amp;lt;record&amp;gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; ENDIF.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ENDLOOP.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;more problematic, as &amp;lt;record&amp;gt; becomes unassigned. HASHED tables need more care with the delete, but the principle holds: generally there is no issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 06:28:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287650#M1832550</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2014-04-18T06:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287651#M1832551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;Dear RamaKrishnan&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;you can try this way ...&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;with in the loop , if the condition satisfies set the flag variable and then delete the records after the loop if the flag is set.&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;LOOP AT lt_beleg into lw_beleg.&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;IF &amp;lt;CONDITION&amp;gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;move 'x' to flag.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;ENDIF.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;END LOOP.&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG style="color: #333333; font-family: inherit; font-size: 12px; font-style: inherit;"&gt;DELETE lt_rot where flag eq 'x'.&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG style="color: #333333; font-family: inherit; font-size: 12px; font-style: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12px; color: #333333;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG style="color: #333333; font-family: inherit; font-size: 12px; font-style: inherit;"&gt;hope it helps.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 06:31:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287651#M1832551</guid>
      <dc:creator>former_member193512</dc:creator>
      <dc:date>2014-04-18T06:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287652#M1832552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Matthew,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You are right. I should have phrased it better.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I meant for the case wherein there is no check involved inside loop but only just plain DELETE statement.&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 06:33:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287652#M1832552</guid>
      <dc:creator>Arun_Prabhu_K</dc:creator>
      <dc:date>2014-04-18T06:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287653#M1832553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's nonsense. This program simply will not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you wanted to do something similar, you'd have to update a delete flag field in each record of the table, But what would be the point? You might as well put the delete in the loop. You're just making the program more inefficient.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 06:36:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287653#M1832553</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2014-04-18T06:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287654#M1832554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ramakrishnan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Please filter &lt;STRONG style="font-size: 12px; color: #333333;"&gt;BELNR&lt;/STRONG&gt; records while fetching in select query using 'for all entries' without deleting in loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; For Ex:&lt;/P&gt;&lt;P&gt;if the BELEG and ROT are database tables.&lt;/P&gt;&lt;P&gt; select * from BELEG into table lt_beleg where condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if lt_beleg is not initial.&lt;/P&gt;&lt;P&gt; select * from ROT into table lt_rot for all entries in lt_beleg where ( belnr = lt_beleg-belnr and belnr &amp;lt;&amp;gt; space ).&lt;/P&gt;&lt;P&gt;endif.&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;Srikanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 06:42:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287654#M1832554</guid>
      <dc:creator>srikanthv2</dc:creator>
      <dc:date>2014-04-18T06:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287655#M1832555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear &lt;STRONG style="font-size: 11px; color: #333333;"&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="17531" data-externalid="" data-presence="null" data-userid="24079" data-username="matthew.billingham" href="https://answers.sap.com/people/matthew.billingham" style="padding: 0 3px 0 0; font-weight: inherit; font-style: inherit; font-size: 1.1em; font-family: inherit; color: #3778c7;"&gt;Matthew Billingham&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;As Ramakrishnan wrote &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt; " is there any other way to handle the code"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;i am trying to answer that , as you told in case of field symbols we cannot delete the record &lt;/P&gt;&lt;P&gt;with in the loop as it unassigns the workarea, i think in that case we can use it ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; if any thing is wrong or if i understood wrongly, could you please correct me ,thankyou.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Shravan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 06:49:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287655#M1832555</guid>
      <dc:creator>former_member193512</dc:creator>
      <dc:date>2014-04-18T06:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287656#M1832556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I can understand that, I can go ahead with the same coding as am not deleting the it_table with the same looped it_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not, please correct me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;RAM. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 06:53:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287656#M1832556</guid>
      <dc:creator>former_member197475</dc:creator>
      <dc:date>2014-04-18T06:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287657#M1832557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can delete records within the loop with ASSIGNING: You just need to be aware that you can't address the record afterwards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 07:01:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287657#M1832557</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2014-04-18T07:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287658#M1832558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh come on. Don't use FOR ALL ENTRIES. Use a JOIN.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 07:01:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287658#M1832558</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2014-04-18T07:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287659#M1832559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;K.Arun Prabhu wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Matthew,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You are right. I should have phrased it better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I meant for the case wherein there is no check involved inside loop but only just plain DELETE statement.&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Still doesn't make sense to me. What do you mean "no check involved"? If there's no check, you can't use WHERE in the first place? Anyway I've done things like this quite happily.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOOP AT itab INTO wa.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;lt;logic&amp;gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DELETE itab.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;lt;more logic&amp;gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ENDLOOP.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 07:04:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287659#M1832559</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2014-04-18T07:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287660#M1832560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are solely deleting records that meet a condition, use DELETE...WHERE...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looping through a table and deleting from that table &lt;STRONG&gt;is not a problem. &lt;/STRONG&gt;Depending what you are doing, it might be good programming.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 07:05:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287660#M1832560</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2014-04-18T07:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287661#M1832561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matthew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your well explanation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Closing this thread.&lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro_emoticon jive_macro jive_emote" src="https://community.sap.com/718/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;RAM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 07:15:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287661#M1832561</guid>
      <dc:creator>former_member197475</dc:creator>
      <dc:date>2014-04-18T07:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287662#M1832562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your idea Shraven.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;RAM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 07:16:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287662#M1832562</guid>
      <dc:creator>former_member197475</dc:creator>
      <dc:date>2014-04-18T07:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287663#M1832563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Matthew,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You again got me wrong. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I meant a case exactly like&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loop at itab where field = value.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete itab.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endloop.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Naive programmers usually code as above.&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Comparatively, &lt;STRONG&gt;delete itab where field = value&lt;/STRONG&gt; is better in terms of performance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 07:28:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287663#M1832563</guid>
      <dc:creator>Arun_Prabhu_K</dc:creator>
      <dc:date>2014-04-18T07:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287664#M1832564</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;another way is , create a range for type BELNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop.&lt;/P&gt;&lt;P&gt;fill range r_belnr.&lt;/P&gt;&lt;P&gt;endloop.&lt;BR /&gt;after looping , write delete statement.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DELETE lt_rot where BELNR in r_belnr.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;regards,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Satyen T.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 07:39:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287664#M1832564</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-18T07:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287665#M1832565</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;You can aslo try in this way,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, generally it is not advisable to use Delete Statements under the Loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when you want to compare records of another internal table then there is no other go we have to use delete statement under the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have slightly modified the code, try this off.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SORT lt_beleg by BELNR.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SORT lt_rot&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by BELNR.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT lt_beleg into lw_beleg.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Read table lt_rot into LS_ROT with key BELNR = lw_beleg-BELNR&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BINARY SEARCH.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if sy-subrc eq 0.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;DELETE lt_rot where BELNR = LS_ROT-BELNR.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;endif.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;clear: LS_ROT, LW_BELEG.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;END LOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Regards,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Saravanan Sambandam&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 07:39:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287665#M1832565</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-18T07:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287666#M1832566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is what I disagree with. There is no general principle of not using DELETE in a loop. In many cases it is exactly the thing to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh, and don't use SORT and BINARY SEARCH. Use SORTED tables - or even better, HASHED tables from the start! They've only been part of the ABAP language for over fifteen years!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 07:58:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287666#M1832566</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2014-04-18T07:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE records within the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287667#M1832567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;bt we can delete the record outside the loop.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DELETE lt_rot where BELNR in r_belnr.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;No need to write delete statement within the loop.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Apr 2014 08:02:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-records-within-the-loop/m-p/10287667#M1832567</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-18T08:02:30Z</dc:date>
    </item>
  </channel>
</rss>

