<?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: A problem with two loops. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195703#M129606</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Phani Kiran Nudurupati, Yes, the where condition are the key fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Jan 2006 20:35:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-01-17T20:35:17Z</dc:date>
    <item>
      <title>A problem with two loops.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195696#M129599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, experts! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My program need to print the data when the account&lt;/P&gt;&lt;P&gt;number, company_code and profit_center are equals between two tables &amp;lt;b&amp;gt;(T_ITAB1, T_ITAB2)&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two loops like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT t_itab1 INTO WA_ITAB.

LOOP at T_ITAB2 WHERE  account = wa_itab-RACCT AND    
        PROFIT_CENTER = wa_itab-prctr and company_code = 
        wa_itab-rbukrs.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The T_ITAB2 have data that is key. No have  repeatedly data and the relationship is one to one. But when I execute the program the information of the internal table T_ITAB2 is repeatedly many times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I resolve this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2006 20:23:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195696#M129599</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-17T20:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with two loops.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195697#M129600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Carlos,&lt;/P&gt;&lt;P&gt;   You can do a read statement on T_ITAB2 to get single value &amp;amp; use &lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt; Can you tell me whether the where condition fields are the key fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2006 20:28:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195697#M129600</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-17T20:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with two loops.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195698#M129601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Instead of looping around itab2, read it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;like this&lt;/P&gt;&lt;P&gt;LOOP AT t_itab1 INTO WA_ITAB.&lt;/P&gt;&lt;P&gt;read table T_ITAB2 into wa_itab2  with key  account = wa_itab-RACCT AND            PROFIT_CENTER = wa_itab-prctr and company_code =         wa_itab-rbukrs.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;*Do something&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&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;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2006 20:28:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195698#M129601</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-17T20:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with two loops.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195699#M129602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SORT T_ITAB2 by account PROFIT_CENTER company_code.
LOOP AT t_itab1 INTO WA_ITAB.
 
read table T_ITAB2 with key
  account       = wa_itab-RACCT
  PROFIT_CENTER = wa_itab-prctr
  company_code  = wa_itab-rbukrs
  binary search.

ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2006 20:30:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195699#M129602</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-17T20:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with two loops.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195700#M129603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do it the other way around..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at Itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab1 comparing keys from itab2.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;  write : Itab2 field values...&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EndLoop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2006 20:32:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195700#M129603</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-17T20:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with two loops.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195701#M129604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi carlos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort both the internal tables on key fields(same in both tables)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Loop on itab1.&lt;/P&gt;&lt;P&gt;  clear itab2.&lt;/P&gt;&lt;P&gt;  read table itab2 with key1 = itab1-key1....&lt;/P&gt;&lt;P&gt;  if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;  &amp;lt;process&amp;gt;&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;Endloop.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2006 20:33:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195701#M129604</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-17T20:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with two loops.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195702#M129605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;it seems as if you had duplicate entries in your internal tables.&lt;/P&gt;&lt;P&gt;Have a look at abap sentence: &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;DELETE ADJACENT DUPLICATE ENTRIES FROM &amp;lt;itab&amp;gt; &lt;/P&gt;&lt;P&gt;[COMPARING &amp;lt;f1&amp;gt; &amp;lt;f 2&amp;gt; ... &lt;/P&gt;&lt;P&gt;|ALL FIELDS].&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;... before processing both loops.&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2006 20:34:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195702#M129605</guid>
      <dc:creator>former_member182371</dc:creator>
      <dc:date>2006-01-17T20:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with two loops.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195703#M129606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Phani Kiran Nudurupati, Yes, the where condition are the key fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2006 20:35:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195703#M129606</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-17T20:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with two loops.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195704#M129607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Carlos,are these the Key fields for the first table also T_ITAB1.&lt;/P&gt;&lt;P&gt;If yes then you can go with the read statement on the T_ITAB2 with the same where condition.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2006 20:43:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195704#M129607</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-17T20:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: A problem with two loops.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195705#M129608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Even though you have unique records in T_ITAB2 for the combination of account number, company code, and profit center, the outer loop of T_ITAB1 may be having duplicate records for this combination. It is like looping at items table and within that looking at the header table with the key. Even though there is only one header record for each key, there may be several items for that header table, so obviously you will see repetetion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May be you need to reverse the order of the loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jan 2006 05:04:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/a-problem-with-two-loops/m-p/1195705#M129608</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-01-18T05:04:37Z</dc:date>
    </item>
  </channel>
</rss>

