<?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 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073686#M1504963</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It was My Mistake&lt;/P&gt;&lt;P&gt;Actaully answer is &lt;/P&gt;&lt;P&gt;At the end of loop processing (i.e. after ENDLOOP ), the return code value of SY-SUBRC specifies whether the loop was actually processed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-SUBRC = 0 The loop was executed at least once. &lt;/P&gt;&lt;P&gt;SY_SUBRC = 4 The loop was not executed, either because there was no entry at all or because there was no entry which satisfied the conditions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Jul 2010 05:33:49 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-07-20T05:33:49Z</dc:date>
    <item>
      <title>loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073673#M1504950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT gt_final INTO gs_final.
LOOP AT gt_i_shipment INTO gs_i_shipment 
WHERE vbeln =  gs_final-vbeln  AND posnr = gs_final-posnr.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eventhough i have corresponding value in gt_i_shipment.for some values it reads for some it doesnt.SY-SUBRC returns non zero.its not reading for some entries .any solutions please.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 11:59:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073673#M1504950</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-19T11:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073674#M1504951</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;the code seems ok.. Might be in some cases the vblen or posnr might have leading zero's but in the other table not having them something like this.. check care fully the values in the two internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nagaraj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 12:04:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073674#M1504951</guid>
      <dc:creator>former_member404244</dc:creator>
      <dc:date>2010-07-19T12:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073675#M1504952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i recommend you to set a breakpoint in the second loop... and check where conditions at runtime...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that will help you to find the problem!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 12:12:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073675#M1504952</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-19T12:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073676#M1504953</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;data is same in both the cases.Should i sort before loop.?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 12:44:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073676#M1504953</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-19T12:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073677#M1504954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no... sorting just will help on perfomance...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mmm. if you are sure that data is equal in both tables... mmmm maybe you should check data elements ... must be the same too&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 13:22:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073677#M1504954</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-19T13:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073678#M1504955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually you didn't show us the code before the two ENDLOOP statements. May be you are changing one or both of the two loop tables? Are you deleting any of the records from any internal table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you sure that the formatting of VBELN and POSNR is the always the same with leading zeros and so on? It may be that any conversion exit hides this kind of information in debugger.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 14:08:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073678#M1504955</guid>
      <dc:creator>MichiFr</dc:creator>
      <dc:date>2010-07-19T14:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073679#M1504956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;THIS IS MY CODE&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; LOOP AT gt_final INTO gs_final.
LOOP AT gt_i_shipment INTO gs_i_shipment 
WHERE vbeln =  gs_final-vbeln  AND posnr = gs_final-posnr.
      
      gs_final-knota       =  gs_i_shipment-knota .
      gs_final-shtyp       =  gs_i_shipment-shtyp .
      gs_final-wadat       =  gs_i_shipment-wadat .
      gs_final-dplen       =  gs_i_shipment-dplen .
    MODIFY  gt_final FROM gs_final.
    CLEAR : gs_i_shipment,gs_kna1,gs_jest.
    ENDLOOP.

    CLEAR :gs_final.
  ENDLOOP. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 14:23:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073679#M1504956</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-19T14:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073680#M1504957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;maybe the entries that doesnt satisfied the conditions are the ones with sy-subrc &amp;lt;&amp;gt; 0???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 15:04:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073680#M1504957</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-19T15:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073681#M1504958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But you didn't show where you are checking sy-subrc!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 19:05:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073681#M1504958</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-19T19:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073682#M1504959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;about loop within loop , you can refer to the following code:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Method One:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Entries: 100 (ITAB1), 1000 (ITAB2)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Line width: 100&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Both tables sorted by key K&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA1.&lt;/P&gt;&lt;P&gt;  LOOP AT ITAB2 INTO WA2&lt;/P&gt;&lt;P&gt;                WHERE K = WA1-K.&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;&lt;STRONG&gt;Method Two:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Entries: 100 (ITAB1), 1000 (ITAB2)&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Line width: 100&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Both tables sorted by key K&lt;/P&gt;&lt;/LI&gt;&lt;/UL&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;the method two is faster than the method one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 01:39:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073682#M1504959</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-20T01:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073683#M1504960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT gt_final INTO gs_final.
LOOP AT gt_i_shipment INTO gs_i_shipment 
WHERE vbeln =  gs_final-vbeln  AND posnr = gs_final-posnr.
     check sy-subrc = 0. &amp;lt;-----------------------------------------Here i AM CHECKING
      gs_final-knota       =  gs_i_shipment-knota .
      gs_final-shtyp       =  gs_i_shipment-shtyp .
      gs_final-wadat       =  gs_i_shipment-wadat .
      gs_final-dplen       =  gs_i_shipment-dplen .
    MODIFY  gt_final FROM gs_final.
    CLEAR : gs_i_shipment,gs_kna1,gs_jest.
    ENDLOOP.
 
    CLEAR :gs_final.
  ENDLOOP. &lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 04:55:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073683#M1504960</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-20T04:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073684#M1504961</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;Are you sure the value of SY-SUBRC is set in the LOOP ... WHERE block. I read the documentation &amp;amp; do not find it mentioned there. Check what is the value of SY-SUBRC before the LOOP statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 05:03:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073684#M1504961</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-07-20T05:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073685#M1504962</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 beleive you should use Read statement inside the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;like:&lt;/P&gt;&lt;P&gt;loop at gt_final into gs_final.&lt;/P&gt;&lt;P&gt;Read table gt_i_shipment into gs_i_shipment &lt;/P&gt;&lt;P&gt;where vbeln = gs_final-vbeln and posnr = gs_final-posnr.&lt;/P&gt;&lt;P&gt;     gs_final-knota       =  gs_i_shipment-knota .&lt;/P&gt;&lt;P&gt;      gs_final-shtyp       =  gs_i_shipment-shtyp .&lt;/P&gt;&lt;P&gt;      gs_final-wadat       =  gs_i_shipment-wadat .&lt;/P&gt;&lt;P&gt;      gs_final-dplen       =  gs_i_shipment-dplen .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; MODIFY  gt_final FROM gs_final.&lt;/P&gt;&lt;P&gt;endloop. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this will improve the performance of your code.&lt;/P&gt;&lt;P&gt;because you are already applying loop on gt_final and checking the vbeln and posnr from gt_final, so there is no need of applying llop at gt_i_shipment.&lt;/P&gt;&lt;P&gt;I hope this will work for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Lalit Gupta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 05:12:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073685#M1504962</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-20T05:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073686#M1504963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It was My Mistake&lt;/P&gt;&lt;P&gt;Actaully answer is &lt;/P&gt;&lt;P&gt;At the end of loop processing (i.e. after ENDLOOP ), the return code value of SY-SUBRC specifies whether the loop was actually processed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-SUBRC = 0 The loop was executed at least once. &lt;/P&gt;&lt;P&gt;SY_SUBRC = 4 The loop was not executed, either because there was no entry at all or because there was no entry which satisfied the conditions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 05:33:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073686#M1504963</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-20T05:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: loop within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073687#M1504964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI &lt;/P&gt;&lt;P&gt;just apply If sy-subrc = 0 after reading the table .&lt;/P&gt;&lt;P&gt;see below:&lt;/P&gt;&lt;P&gt;loop at gt_final into gs_final.&lt;/P&gt;&lt;P&gt;Read table gt_i_shipment into gs_i_shipment &lt;/P&gt;&lt;P&gt;where vbeln = gs_final-vbeln and posnr = gs_final-posnr.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;then &lt;/P&gt;&lt;P&gt;move your fields.&lt;/P&gt;&lt;P&gt;in this case only the values will be moved if there is a matching value of vbeln and posnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;no need to check sy-subrc after the endloop statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Lalit Gupta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 05:37:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-within-loop/m-p/7073687#M1504964</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-20T05:37:19Z</dc:date>
    </item>
  </channel>
</rss>

