<?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 in LOOP Problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644284#M877579</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="blue" __jive_macro_name="color"&gt;
Hi Rahul But,
If your ITAB1 can have multiple same documents numbers, before loop and endloop, SORT itab1 by belnr. Samething at ITAB2.

Then write code like this.

&lt;PRE&gt;&lt;CODE&gt;data:l_first_belnr type c.
LOOP AT ITAB1.
    at new belnr.
     l_first_belnr = 'X'.
     endat.
    if l_first_belnr = 'X'.
         LOOP AT ITAB2 WHERE BELNR = ITAB1-BELNR
            w_index = w_index + 1.
            .
            .
            .
            .
           MODIFY ITAB1 INDEX W_INDEX TRANSPORTING 
           SOMETHING.
         ENDLOOP.
   clear l_first_belnr.
  endif.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt; 
I hope that helps you.

Regards,
Venkat.O
&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 12 Apr 2008 08:36:18 GMT</pubDate>
    <dc:creator>venkat_o</dc:creator>
    <dc:date>2008-04-12T08:36:18Z</dc:date>
    <item>
      <title>LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644281#M877576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a code which is like this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1.&lt;/P&gt;&lt;P&gt; LOOP AT ITAB2 WHERE BELNR = ITAB1-BELNR&lt;/P&gt;&lt;P&gt; w_index = w_index + 1.&lt;/P&gt;&lt;P&gt;   .&lt;/P&gt;&lt;P&gt;   .&lt;/P&gt;&lt;P&gt;   .&lt;/P&gt;&lt;P&gt;   .&lt;/P&gt;&lt;P&gt;  MODIFY ITAB1 INDEX W_INDEX TRANSPORTING SOMETHING.&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;Now what i want is that suppose while looping ITAB1 for the first time doc no(belnr) 12345 comes and loop at itab2 gets executed...&lt;/P&gt;&lt;P&gt;Now after this inner loop is completed and in ITAB1 again  if doc no(belnr) 12345 comes again,then the inner loop LOOP AT ITAB2 should not get executed again until some other doc no other than 12345 comes again...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if this problem is solved then my index problem for modifying will get resolved i guess.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Apr 2008 07:11:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644281#M877576</guid>
      <dc:creator>rahul2000</dc:creator>
      <dc:date>2008-04-12T07:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644282#M877577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;instead of writing two loop statements loop one itab and then write read statement and then use modify statement&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Apr 2008 07:28:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644282#M877577</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-12T07:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644283#M877578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   get the ITAB1 belnr in to a variable.&lt;/P&gt;&lt;P&gt;and in the inner loop check the value .&lt;/P&gt;&lt;P&gt;if it is same write &lt;STRONG&gt;continue&lt;/STRONG&gt; statement.&lt;/P&gt;&lt;P&gt;u need to every time in the sense for every iteration of ITAB1 store the new belnr in the variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if helpful&lt;/P&gt;&lt;P&gt;raam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Apr 2008 07:37:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644283#M877578</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-12T07:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644284#M877579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="blue" __jive_macro_name="color"&gt;
Hi Rahul But,
If your ITAB1 can have multiple same documents numbers, before loop and endloop, SORT itab1 by belnr. Samething at ITAB2.

Then write code like this.

&lt;PRE&gt;&lt;CODE&gt;data:l_first_belnr type c.
LOOP AT ITAB1.
    at new belnr.
     l_first_belnr = 'X'.
     endat.
    if l_first_belnr = 'X'.
         LOOP AT ITAB2 WHERE BELNR = ITAB1-BELNR
            w_index = w_index + 1.
            .
            .
            .
            .
           MODIFY ITAB1 INDEX W_INDEX TRANSPORTING 
           SOMETHING.
         ENDLOOP.
   clear l_first_belnr.
  endif.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt; 
I hope that helps you.

Regards,
Venkat.O
&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Apr 2008 08:36:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644284#M877579</guid>
      <dc:creator>venkat_o</dc:creator>
      <dc:date>2008-04-12T08:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644285#M877580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rahul,&lt;/P&gt;&lt;P&gt;Check below the effective way to achieve ur requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Mandatory to use AT NEW event in this case is BELNR&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;should be first field of the tables.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT: itab1 BY belnr,&lt;/P&gt;&lt;P&gt;           itab2 BY belnr.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO wa_tab1.&lt;/P&gt;&lt;P&gt;CLEAR itab1.&lt;/P&gt;&lt;P&gt; itab1 = wa_tab1.&lt;/P&gt;&lt;P&gt;AT NEW belnr.&lt;/P&gt;&lt;P&gt;READ TABLE itab2 WITH KEY belnr = itab1-belnr &lt;/P&gt;&lt;P&gt;BINARY SEARCH&lt;/P&gt;&lt;P&gt;TRANSPORTING NO FIELDS.  &lt;/P&gt;&lt;P&gt;CHECK sy-subrc IS INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR w_index1.&lt;/P&gt;&lt;P&gt;w_index1 = sy-tabix.&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;To reduce number of loop passes loop from the index.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If we use where clause then full table scan will happens.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB2 FROM w_index1.&lt;/P&gt;&lt;P&gt;w_index = w_index + 1.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;MODIFY ITAB1 INDEX W_INDEX TRANSPORTING SOMETHING.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinod.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Apr 2008 14:13:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644285#M877580</guid>
      <dc:creator>vinod_vemuru2</dc:creator>
      <dc:date>2008-04-12T14:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644286#M877581</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;u can use the read index  statement at the first loop or u can use the count ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if count = something..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;exit..&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;something..&lt;/P&gt;&lt;P&gt;endid.&lt;/P&gt;&lt;P&gt;like that..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;venkat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Apr 2008 15:37:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644286#M877581</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-12T15:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644287#M877582</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;Pls try to use some flag in ur code and try to fix it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Apr 2008 17:16:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644287#M877582</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-12T17:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644288#M877583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vinod,&lt;/P&gt;&lt;P&gt;Thanks a ton...&lt;/P&gt;&lt;P&gt;I will be getting back to work on tuesday...&lt;/P&gt;&lt;P&gt;Looking at u r solution...my guess is that it will work...&lt;/P&gt;&lt;P&gt;Will BELNR have to be the first field in both my internal tables??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a ton...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I will surely reward each and everyone..&lt;/P&gt;&lt;P&gt;Thanks a ton..&lt;/P&gt;&lt;P&gt;Will get back to u on tuesday&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Apr 2008 18:26:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644288#M877583</guid>
      <dc:creator>rahul2000</dc:creator>
      <dc:date>2008-04-12T18:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644289#M877584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Rahul,&lt;/P&gt;&lt;P&gt;U R Right. Belnr should be the first field of both tables. But It is not like AT EVENT Field should always be the first field. Suppose u have belnr as second field of ur internal table and if u use AT NEW belnr then when ever ur first field or belnr changes then control will enter in to this block. i.e. It will take till the field in AT event as key. If any field with in the key changes then control will enter. Hope u understood how AT EVENT works. Another thing is SORT is Mandatory for AT EVENTS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinod.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Apr 2008 05:15:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644289#M877584</guid>
      <dc:creator>vinod_vemuru2</dc:creator>
      <dc:date>2008-04-13T05:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644290#M877585</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 cant make the field BELNR as the first field go like this....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : W_BELNR TYPE BELNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT: itab1 BY belnr,&lt;/P&gt;&lt;P&gt;           itab2 BY belnr.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF ITAB-BELNR &amp;lt;&amp;gt; W_BELNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB2 WHERE BELNR =  ITAB1-BELNR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;W_BELNR  =  ITAB1-BELNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Apr 2008 05:45:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644290#M877585</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-13T05:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP in LOOP Problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644291#M877586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vinod,&lt;/P&gt;&lt;P&gt;Yup i did understand hot these AT events work.&lt;/P&gt;&lt;P&gt;Thanks a ton.&lt;/P&gt;&lt;P&gt;Will get back to you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Apr 2008 12:31:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-in-loop-problem/m-p/3644291#M877586</guid>
      <dc:creator>rahul2000</dc:creator>
      <dc:date>2008-04-13T12:31:32Z</dc:date>
    </item>
  </channel>
</rss>

