<?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: How to avoid loop inside loop. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-loop-inside-loop/m-p/8926973#M1692108</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Hi Jalina,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="j-status-levels" style="font-style: inherit; font-family: inherit;"&gt;&lt;IMG alt="Not Active Contributor" class="jiveImage" src="https://community.sap.com/843/plugins/points/resources/images/not-active-contributor.gif" style="margin: 0 10px 0 0; font-style: inherit; font-family: inherit;" title="Not Active Contributor" /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="j-status-levels" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt;Kindly go through following link this will surly help you to improve your performance of nested loop.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="j-status-levels" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt;&lt;A href="http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+Code+for+Parallel+Cursor+-+Loop+Processing" title="http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+Code+for+Parallel+Cursor+-+Loop+Processing"&gt;http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+Code+for+Parallel+Cursor+-+Loop+Processing&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="j-status-levels" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt;Regards,&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="j-status-levels" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt;Pushkar.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Aug 2012 08:32:57 GMT</pubDate>
    <dc:creator>pushkar_dhale</dc:creator>
    <dc:date>2012-08-01T08:32:57Z</dc:date>
    <item>
      <title>How to avoid loop inside loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-loop-inside-loop/m-p/8926971#M1692106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am BW Consultant and i have written Functio Module extraction using the ABAP Code. Please find the below ABAP Code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using Z table Z175 and BSEG table and moving the data to final internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Z175, Billing document field is there. It contains more than 1 data for a single billing document and &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BSEG table will also have more than 1 data for a single billing document. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using the Condition Z175-VBELN = BSEG-BELNR i am pulling the data for other fields such as GL Account, Group Account and other details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written the code as loop inside the Loop. Because of this, it is affecting the performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please help me on modifying the attached code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;Moderator Message: &lt;SPAN __jive_emoticon_name="info" __jive_macro_name="emoticon" class="jive_macro jive_macro_emoticon jive_emote" src="https://community.sap.com/843/images/emoticons/info.gif"&gt;&lt;/SPAN&gt; Search the internet with search terms viz., Parallel cursor for LOOPs, Nested loop optimisation using SORTED TABLEs. Personally i use the latter.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Suhas Saha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Aug 2012 06:50:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-loop-inside-loop/m-p/8926971#M1692106</guid>
      <dc:creator>former_member184624</dc:creator>
      <dc:date>2012-08-01T06:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid loop inside loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-loop-inside-loop/m-p/8926972#M1692107</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;There is no use of us seeing your attached code, because as you have mentioned, you are usilng a custom table and we will not know the fields of the custom table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyways a small advice, it is the developer who should judge for himself if a loop inside loop is really necessary, in many cases it is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wherever it is necessary, us it, if you think that is the best solution. One more thing that you can do is to use parallel cursor while using loop inside loop. Parallel cusrsor is a technique of looping through the inner loop as few times as possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at lt_outer into ls_outer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lv_index = sy-tabix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loop at lt_inner into ls_inner from lv_index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 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;it can also be achieved&amp;nbsp; by a where clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at lt_outer into ls_outer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loop at lt_inner into ls_inner&lt;/P&gt;&lt;P&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; where field eq ls_outer-field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loop.&lt;/P&gt;&lt;P&gt;loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps you. Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kartik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Aug 2012 07:07:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-loop-inside-loop/m-p/8926972#M1692107</guid>
      <dc:creator>Kartik2</dc:creator>
      <dc:date>2012-08-01T07:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid loop inside loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-loop-inside-loop/m-p/8926973#M1692108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Hi Jalina,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="j-status-levels" style="font-style: inherit; font-family: inherit;"&gt;&lt;IMG alt="Not Active Contributor" class="jiveImage" src="https://community.sap.com/843/plugins/points/resources/images/not-active-contributor.gif" style="margin: 0 10px 0 0; font-style: inherit; font-family: inherit;" title="Not Active Contributor" /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="j-status-levels" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt;Kindly go through following link this will surly help you to improve your performance of nested loop.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="j-status-levels" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt;&lt;A href="http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+Code+for+Parallel+Cursor+-+Loop+Processing" title="http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+Code+for+Parallel+Cursor+-+Loop+Processing"&gt;http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+Code+for+Parallel+Cursor+-+Loop+Processing&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="j-status-levels" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt;Regards,&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="j-status-levels" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt;Pushkar.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Aug 2012 08:32:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-avoid-loop-inside-loop/m-p/8926973#M1692108</guid>
      <dc:creator>pushkar_dhale</dc:creator>
      <dc:date>2012-08-01T08:32:57Z</dc:date>
    </item>
  </channel>
</rss>

