<?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: loop on internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881653#M370178</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;I hope following code will solve your problem.&lt;/P&gt;&lt;P&gt;LOOP AT t_itab.&lt;/P&gt;&lt;P&gt;READ TABLE t_final WITH KEY objnr = t_itab-objnr.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if the answer is helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mukul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Jan 2007 14:18:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-01-23T14:18:39Z</dc:date>
    <item>
      <title>loop on internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881652#M370177</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;I have two internal tables. T_FINAL and T_ITAB.&lt;/P&gt;&lt;P&gt;for each record in T_FINAL there are more than one record in T_ITAB.&lt;/P&gt;&lt;P&gt;OBJNR is the common field.&lt;/P&gt;&lt;P&gt;I have to duplicate the entries in T_FINAL table wrt corresponding entries in T_ITAB based on OBJNR. &lt;/P&gt;&lt;P&gt; Tables are pretty big. How do i go about doing this with optimized results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;amit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:15:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881652#M370177</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: loop on internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881653#M370178</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;I hope following code will solve your problem.&lt;/P&gt;&lt;P&gt;LOOP AT t_itab.&lt;/P&gt;&lt;P&gt;READ TABLE t_final WITH KEY objnr = t_itab-objnr.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if the answer is helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mukul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:18:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881653#M370178</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: loop on internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881654#M370179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;we have to use nested loops only i guess for this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at t_final.
 loop at t_itab where objnr eq t_final-objnr.
  move-corresponding t_itab to t_final.
  append t_final.
  clear t_final.
 endloop.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:19:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881654#M370179</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: loop on internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881655#M370180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is taken fro SE30 hints and tips. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I = 1.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA1.&lt;/P&gt;&lt;P&gt;  LOOP AT ITAB2 INTO WA2 FROM I.&lt;/P&gt;&lt;P&gt;    IF WA2-K &amp;lt;&amp;gt; WA1-K.&lt;/P&gt;&lt;P&gt;      I = SY-TABIX.&lt;/P&gt;&lt;P&gt;      EXIT.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    " ...&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is the best way to run a nested loop. If you are going to use the read statement, also use the BINARY SEARCH command otherwise it will run slow, especially as you mentioned that there are many entries in the table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:21:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881655#M370180</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: loop on internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881656#M370181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks chandra.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what if objnr is blank in t_final ... i will miss that record ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:26:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881656#M370181</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: loop on internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881657#M370182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;loop at t_itab .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   loop at t_final where objnr = t_itab-objnr .&lt;/P&gt;&lt;P&gt;    .&lt;/P&gt;&lt;P&gt;    .&lt;/P&gt;&lt;P&gt;   endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can change you logic while filling internal table some different logic can also be applied which would be more efficiant .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:26:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881657#M370182</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: loop on internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881658#M370183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you use this code: -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_final.&lt;/P&gt;&lt;P&gt; loop at t_itab where objnr eq t_final-objnr.&lt;/P&gt;&lt;P&gt;  move-corresponding t_itab to t_final.&lt;/P&gt;&lt;P&gt;  append t_final.&lt;/P&gt;&lt;P&gt;  clear t_final.&lt;/P&gt;&lt;P&gt; endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It will run very slowly. Beleive me I know, I had the same problem. For every record in t_final, it will start reading every record in t_itab. So if you  have 10000 records in t_final, it will read all of the records in t_itab 10000 times. If there are 10000 records in t_itab, the number of records read will be 10000 * 10000. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If u use the method I have mentioned, you will not have this problem. The index is stored when reading the table t_itab. Therefore the same record is never read more than once.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do not use this method, then do not put another posting on here moaning about the performance of the nested loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:36:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881658#M370183</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: loop on internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881659#M370184</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;P&gt;/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2007 14:54:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-internal-table/m-p/1881659#M370184</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-01-23T14:54:15Z</dc:date>
    </item>
  </channel>
</rss>

