<?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: Loops within loops in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899484#M935776</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;write:&lt;/P&gt;&lt;P&gt;select * from hrp1001 into table lt_hrp1001&lt;/P&gt;&lt;P&gt;where plvar = '01'&lt;/P&gt;&lt;P&gt;and relat IN ('Z40','008').&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Jun 2008 09:21:55 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-03T09:21:55Z</dc:date>
    <item>
      <title>Loops within loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899479#M935771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings Abapers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I keep getting a runtime error where the system tells me that my program has terminated because it has exceeded the runtime limit. I suspect this is because i have a loop within another loop and they both take a while to execute. I was wondering if you could suggest how i can improve my code. Currently what i want to do is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get all active sales codes and assign them to a table&lt;/P&gt;&lt;P&gt;Read org relationships for all BP's linked to Salescodes for all date ranges&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code is :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at lt_/ccdev01/a2scode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     Read all organisational relationships for all business partneru2019s linked to sales codes for all date ranges&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  select * from hrp1001 into table lt_hrp1001&lt;/P&gt;&lt;P&gt;     where plvar      = '01'&lt;/P&gt;&lt;P&gt;     and  relat       = 'Z40'&lt;/P&gt;&lt;P&gt;     or   relat       = '008'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at lt_hrp1001.&lt;/P&gt;&lt;P&gt;.........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endloop.&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, 03 Jun 2008 09:09:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899479#M935771</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-03T09:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Loops within loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899480#M935772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi try this!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort  lt_/ccdev01/a2scode by &amp;lt;keyfield&amp;gt;.&lt;/P&gt;&lt;P&gt;sort hrp1001 by &amp;lt;key field..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at lt_/ccdev01/a2scode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read all organisational relationships for all business partneru2019s linked to sales codes for all date ranges &lt;/P&gt;&lt;P&gt;select * from hrp1001 into table lt_hrp1001&lt;/P&gt;&lt;P&gt;where plvar = '01'&lt;/P&gt;&lt;P&gt;and relat = 'Z40'&lt;/P&gt;&lt;P&gt;or relat = '008'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;read  table hrp1001 into wa_hrp1001 with key =  lt_/ccdev01/a2scode-&amp;lt;key&amp;gt;.&lt;/STRONG&gt;&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, 03 Jun 2008 09:13:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899480#M935772</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-03T09:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: Loops within loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899481#M935773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your select statement is doing the same work in every loop, better place it outside the loop. And then do a loop within the loop. Just try if it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yogesh Bhatia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jun 2008 09:14:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899481#M935773</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-03T09:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Loops within loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899482#M935774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hrp1001 has huge data and that too UR executing this table&lt;/P&gt;&lt;P&gt;without proper key .. and in loop .. endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select data only once from HRP1001 ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from hrp1001 into table lt_hrp1001&lt;/P&gt;&lt;P&gt;where plvar = '01'&lt;/P&gt;&lt;P&gt;and relat = 'Z40'&lt;/P&gt;&lt;P&gt;or relat = '008'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at lt_/ccdev01/a2scode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at lt_hrp1001.&lt;/P&gt;&lt;P&gt;.........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&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, 03 Jun 2008 09:19:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899482#M935774</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-03T09:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Loops within loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899483#M935775</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;try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;...

select * from hrp1001 into table lt_hrp1001
where plvar = '01'
and relat = 'Z40'
or relat = '008'.

LOOP AT lt_/ccdev01/a2scode ASSIGNING &amp;lt;FS1&amp;gt;.

  LOOP AT LT_HRP1001 ASSIGNING &amp;lt;FS2&amp;gt;.

  ENDLOOP.

ENDLOOP.

...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Futher tipps:&lt;/P&gt;&lt;P&gt;TABLE LT_HRP1001: Sorted or Hashed table&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jun 2008 09:19:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899483#M935775</guid>
      <dc:creator>andr_klos</dc:creator>
      <dc:date>2008-06-03T09:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Loops within loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899484#M935776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;write:&lt;/P&gt;&lt;P&gt;select * from hrp1001 into table lt_hrp1001&lt;/P&gt;&lt;P&gt;where plvar = '01'&lt;/P&gt;&lt;P&gt;and relat IN ('Z40','008').&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jun 2008 09:21:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loops-within-loops/m-p/3899484#M935776</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-03T09:21:55Z</dc:date>
    </item>
  </channel>
</rss>

