<?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 a loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908053#M937149</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;Instead of using loop within loop , use read statement within loop it will improve program performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this below logic..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear wa_bseg.&lt;/P&gt;&lt;P&gt;loop at t_final into wa_final.&lt;/P&gt;&lt;P&gt; read table t_bseg1 into wa_bseg with key belnr = wa_final-belnr&lt;/P&gt;&lt;P&gt;                                                            gjahr = wa_final-gjahr.&lt;/P&gt;&lt;P&gt; if sy-subrc eq 0 .&lt;/P&gt;&lt;P&gt;   wa_final1 = wa_final.&lt;/P&gt;&lt;P&gt;   append wa_final1 to t_final1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;clear: wa_bseg, wa_final1,wa_final.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;N M Poojari.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Nilambari Poojari on May 27, 2008 9:06 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 May 2008 07:05:58 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-27T07:05:58Z</dc:date>
    <item>
      <title>loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908045#M937141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is there anything wrong with this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear wa_bseg.&lt;/P&gt;&lt;P&gt;loop at t_final into wa_final.&lt;/P&gt;&lt;P&gt;  loop at t_bseg1 into wa_bseg where belnr = wa_final-belnr&lt;/P&gt;&lt;P&gt;                               and   gjahr = wa_final-gjahr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*and   zfbdt  = wa_final-zfbdt.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0 .&lt;/P&gt;&lt;P&gt;wa_final1 = wa_final.&lt;/P&gt;&lt;P&gt;append wa_final1 to t_final1.&lt;/P&gt;&lt;P&gt;clear wa_final1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;clear wa_bseg.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;*clear wa_final.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 06:51:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908045#M937141</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T06:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908046#M937142</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;no need of if sy-subrc in side loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;clear wa_bseg.
loop at t_final into wa_final.
loop at t_bseg1 into wa_bseg where belnr = wa_final-belnr
and gjahr = wa_final-gjahr.

   wa_final1 = wa_final.
   append wa_final1 to t_final1.
   clear wa_final1.

   clear wa_bseg.
endloop.
 clear wa_final.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 06:53:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908046#M937142</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T06:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908047#M937143</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 nothing wrong with the code but your code inside the second loop will get executed for no. of rows in outer internal table  multiplied by no. of rows in inner internal table . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to restrict means want to execute the inner loop code only once for each row . &lt;/P&gt;&lt;P&gt;Use exit in the inner loop .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 06:57:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908047#M937143</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T06:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908048#M937144</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 think there is no problem with this code , just check weather sy-subrc value getting updated properly , depending based on internal loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but if data in both internal tables will be more then it's execution time will increase significantly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 06:57:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908048#M937144</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T06:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908049#M937145</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;if you have duplicate entries of belnr and gjahr in the internal table t_final, then there is a possibilty of appending the same data into t_final1. otherwise the code is perfectly fine. as Vijay rightly said, sy-subrc is not needed in loop. if u doign a read then it is required.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 06:57:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908049#M937145</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T06:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908050#M937146</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 dont know your requirement, but after looking at the code, it looks like you want to find all the wa_final for which there is any entry in t_bseg1 table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First of all the check of sy-subrc is not required. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there exists 2 records in t_bseg1 which satisfies the above condition, the wa_final would be appended twice. This can be avoided by using "EXIT" stmt inside the inner loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~ Ramanath.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 06:57:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908050#M937146</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T06:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908051#M937147</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 think there is no problem with this code , just check weather sy-subrc value getting updated properly , depending based on internal loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but if data in both internal tables will be more then it's execution time will increase significantly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 06:57:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908051#M937147</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T06:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908052#M937148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;U need to sort for the fields inside the &lt;/P&gt;&lt;P&gt;loop where ur putting where inserting further more for program performance .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 07:00:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908052#M937148</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T07:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908053#M937149</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;Instead of using loop within loop , use read statement within loop it will improve program performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this below logic..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear wa_bseg.&lt;/P&gt;&lt;P&gt;loop at t_final into wa_final.&lt;/P&gt;&lt;P&gt; read table t_bseg1 into wa_bseg with key belnr = wa_final-belnr&lt;/P&gt;&lt;P&gt;                                                            gjahr = wa_final-gjahr.&lt;/P&gt;&lt;P&gt; if sy-subrc eq 0 .&lt;/P&gt;&lt;P&gt;   wa_final1 = wa_final.&lt;/P&gt;&lt;P&gt;   append wa_final1 to t_final1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;clear: wa_bseg, wa_final1,wa_final.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;N M Poojari.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Nilambari Poojari on May 27, 2008 9:06 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 07:05:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908053#M937149</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T07:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908054#M937150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A READ on a standard table won't significantly improve performance without the BINARY SEARCH addition.&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, 27 May 2008 13:17:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908054#M937150</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T13:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908055#M937151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to use the parallel cursor technique. SE30 has hints and tips. The code you are looking for is this.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 13:23:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908055#M937151</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T13:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908056#M937152</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;1. I think there is one thing wrong according to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. you are looping at the itab  &lt;STRONG&gt;t_final&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;    and inside the loop itself,&lt;/P&gt;&lt;P&gt;    you are appending to the same internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Instead you should take another internal table,&lt;/P&gt;&lt;P&gt;   and move the field values&lt;/P&gt;&lt;P&gt;   and append the records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;amit m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 13:30:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908056#M937152</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T13:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: loop within a loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908057#M937153</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 nothing wrong in your code, but rather using nested loop you can do as below :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at t_final into wa_final.
read t_bseg1 with key where belnr = wa_final-belnr
                                          gjahr = wa_final-gjahr.

if sy-subrc eq 0 .
  wa_final1 = wa_final.
  append wa_final1 to t_final1.
  clear : wa_final,
            wa_final1.
endif.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sriram Ponna.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 13:30:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-a-loop/m-p/3908057#M937153</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T13:30:56Z</dc:date>
    </item>
  </channel>
</rss>

