<?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 Within Loop Alternative in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960925#M946129</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use parallel cursor method....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Jun 2008 12:34:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-23T12:34:40Z</dc:date>
    <item>
      <title>Loop Within Loop Alternative</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960924#M946128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what are the other alternative of avoiding loop withing loop , as it will increase lots of processing and load on system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know these options : &lt;/P&gt;&lt;P&gt;1. for all entries in&lt;/P&gt;&lt;P&gt;2. Joins&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; but it is also not much fruitful as it is having some disadvantages.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2008 12:33:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960924#M946128</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-23T12:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Within Loop Alternative</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960925#M946129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use parallel cursor method....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2008 12:34:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960925#M946129</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-23T12:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Within Loop Alternative</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960926#M946130</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;Follow these links...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3b23358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3b23358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.saptechnical.com/Tutorials/ABAP/ParallelCursor.htm" target="test_blank"&gt;http://www.saptechnical.com/Tutorials/ABAP/ParallelCursor.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://learnabap.blogspot.com/2007/05/performance-tuning-using-parallel.html" target="test_blank"&gt;http://learnabap.blogspot.com/2007/05/performance-tuning-using-parallel.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://karsap.blogspot.com/2007/06/avoiding-nested-loops-using-parallel_19.html" target="test_blank"&gt;http://karsap.blogspot.com/2007/06/avoiding-nested-loops-using-parallel_19.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.articlesbase.com/programming-articles/sap-performance-tuning-using-parallel-cursor-324225.html" target="test_blank"&gt;http://www.articlesbase.com/programming-articles/sap-performance-tuning-using-parallel-cursor-324225.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if useful....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Azad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2008 12:35:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960926#M946130</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-23T12:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Within Loop Alternative</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960927#M946131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;Use loop from sy-tabix&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2008 12:36:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960927#M946131</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-23T12:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Within Loop Alternative</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960928#M946132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hiiii&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use parallel cursor method to avoid it..use it like below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;clear it_s.
clear it_e.
DATA: incd TYPE i, incs TYPE i,inci TYPE i, incf TYPE i.
DATA: it_tmp TYPE ty_t_data WITH HEADER LINE.
it_tmp[] = it_prd[].
DATA: inc TYPE i.
LOOP AT it_prd.

  READ TABLE it_chs WITH KEY
                            spras  w_langu
                             msehi = it_prd-msehi.

    w_tmp = it_prd-msehi.
  IF sy-subrc NE 0.
    WRITE:/ w_tmp.
    APPEND it_prd TO it_s.
    incs = incs + 1.
  ENDIF.
  if sy-subrc EQ 0.
    append it_prd to it_e.
    endif.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if useful&lt;/P&gt;&lt;P&gt;thx&lt;/P&gt;&lt;P&gt;twinkal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2008 12:36:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960928#M946132</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-23T12:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Within Loop Alternative</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960929#M946133</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;In your previous thread, it was suggested Join can be used.&lt;/P&gt;&lt;P&gt;try that, if not use FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;if both are not possible, then use parallel cursor method, as suggested by everyone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;madhu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2008 12:36:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960929#M946133</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-23T12:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Within Loop Alternative</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960930#M946134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   First loop at 1st itab and then read 2nd itab.Both the internal tables should have one common key field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab2 with key k1 = itab1-key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------" /&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2008 12:37:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960930#M946134</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-23T12:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Within Loop Alternative</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960931#M946135</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;Please find the link below which has a tutorial on using the &lt;STRONG&gt;Parallel Cursor&lt;/STRONG&gt; which can be a very good alternative to Loop within Loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.saptechnical.com/Tutorials/ABAP/ParallelCursor.htm" target="test_blank"&gt;http://www.saptechnical.com/Tutorials/ABAP/ParallelCursor.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;R Adarsh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2008 12:46:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960931#M946135</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-23T12:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Within Loop Alternative</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960932#M946136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi as you suggested you can use FOR ALL ENTRIES and JOINS but in case you are not able to check out the Parallel Cursor Method which avoids the nested loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check out these codes :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Conventional Method&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at lt_vbpa into wa_vbpa.
  loop at lt_kna1 into wa_kna1 where kunnr = wa_vbpa-kunnr.

****** Your Actual logic within inner loop ******

  endloop.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parallel Cursor Method&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
sort: lt_vbpa by kunnr,  "Sorting by key is very important
      lt_kna1 by kunnr.  "Same key which is used for where condition is used here
loop at lt_vbpa into wa_vbpa.
  read lt_kna1 into wa_kna1     " This sets the sy-tabix
       with key kunnr = wa_vbpa-kunnr
       binary search.
  if sy-subrc = 0.              "Does not enter the inner loop
    v_kna1_index = sy-tabix.
    loop at lt_kna1 into wa_kna1 from v_kna1_index. "Avoiding Where clause
      if wa_kna1-kunnr &amp;lt;&amp;gt; wa_vbpa-kunnr.  "This checks whether to exit out of loop
        exit.
      endif.

****** Your Actual logic within inner loop ******

   endloop. "KNA1 Loop
  endif.
endloop.  " VBPA Loop

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2008 12:56:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop-alternative/m-p/3960932#M946136</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-23T12:56:22Z</dc:date>
    </item>
  </channel>
</rss>

