<?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: help needed on performance improvement avoiding nested loops in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683774#M887040</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this...&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;itab3-machine = itab2-machine.&lt;/P&gt;&lt;P&gt;itab3-m/c description = itab2-m/c description.&lt;/P&gt;&lt;P&gt;itab3-start time = itab2-start time.&lt;/P&gt;&lt;P&gt;itab3-stop time = itab2-stop time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; read table itab1 with key .....&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;itab3-function name = itab1-function name.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append itab3.&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, 08 Apr 2008 13:34:37 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-08T13:34:37Z</dc:date>
    <item>
      <title>help needed on performance improvement avoiding nested loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683773#M887039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everybody,&lt;/P&gt;&lt;P&gt;Is there any thing similar to "for all entries" for internal tables to fetch multiple records&lt;/P&gt;&lt;P&gt;from an internal table at a time based on certain selection criteria.&lt;/P&gt;&lt;P&gt;We can read only record using "read" statement right. I want to read multiple records&lt;/P&gt;&lt;P&gt;from an internal table at a time without using loop.&lt;/P&gt;&lt;P&gt;I have three internal tables itab1, itab2, itab3. Based on a field value in itab1, I have to fetch&lt;/P&gt;&lt;P&gt;multiple records from itab2 into itab3. itab2 and itab3 are of same line type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab1                                               &lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------" /&gt;&lt;P&gt;          &lt;/P&gt;&lt;P&gt;machine | function name             &lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------" /&gt;&lt;P&gt;          &lt;/P&gt;&lt;P&gt;123        | FM1                          &lt;/P&gt;&lt;P&gt;456        | FM1                           &lt;/P&gt;&lt;P&gt;789        | FM2                                                                                &lt;/P&gt;&lt;P&gt;itab2&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------------------------------------------------------------" /&gt;&lt;P&gt;machine | m/c description | start time | stop time |.....|.....|...&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------" /&gt;&lt;P&gt; 123 | mach1 | 07:00 | 08:00&lt;/P&gt;&lt;P&gt;123 | mach1 | 08:00 | 09:00&lt;/P&gt;&lt;P&gt;123 | mach2 | 06:00 | 08:00&lt;/P&gt;&lt;P&gt;456 | mach2 | 24:00 | 08:00&lt;/P&gt;&lt;P&gt;456 | mach2 | 07:00 | 12:00&lt;/P&gt;&lt;P&gt;789 | mach3 | 04:00 | 09:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I loop over itab1, and get first record, I want to get all records from itab2 corresponding to the machine number in the itab1 at a time into itab3 without using loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sunny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 12:05:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683773#M887039</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T12:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: help needed on performance improvement avoiding nested loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683774#M887040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this...&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;itab3-machine = itab2-machine.&lt;/P&gt;&lt;P&gt;itab3-m/c description = itab2-m/c description.&lt;/P&gt;&lt;P&gt;itab3-start time = itab2-start time.&lt;/P&gt;&lt;P&gt;itab3-stop time = itab2-stop time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; read table itab1 with key .....&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;itab3-function name = itab1-function name.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append itab3.&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, 08 Apr 2008 13:34:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683774#M887040</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T13:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: help needed on performance improvement avoiding nested loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683775#M887041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;Actually I need to loop over itab1 and have to create a new itab3 by using itab2. In itab3, it should contain&lt;/P&gt;&lt;P&gt;the records from itab2 for the corresponding machines(records in itab1) which have same function module in itab1.&lt;/P&gt;&lt;P&gt;In that loop, I used at end of 'function name' and in that event i have to call the function module.&lt;/P&gt;&lt;P&gt;For that funmodule, i have to pass itab3 as a parameter. The purpose is ,the function module which&lt;/P&gt;&lt;P&gt;I called will calculate some values for the records( machines) which I passed as parameter to the function&lt;/P&gt;&lt;P&gt;module. &lt;/P&gt;&lt;P&gt;The main purpose is I want to pass only  records(machines) from itab2 which are relevant to the fun module as a parameter which i am calling in the "at end of fun name". So I am trying to filter records&lt;/P&gt;&lt;P&gt;from itab2 an store it in itab3 based on the fun name value in itab1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab1&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;machine | function name&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;123 | FM1 &lt;/P&gt;&lt;P&gt;456 | FM1 &lt;/P&gt;&lt;P&gt;789 | FM2 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab2&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;machine | m/c description | start time | stop time |.....|.....|...&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;123 | mach1 | 07:00 | 08:00&lt;/P&gt;&lt;P&gt;123 | mach1 | 08:00 | 09:00&lt;/P&gt;&lt;P&gt;123 | mach2 | 06:00 | 08:00&lt;/P&gt;&lt;P&gt;456 | mach2 | 24:00 | 08:00&lt;/P&gt;&lt;P&gt;456 | mach2 | 07:00 | 12:00&lt;/P&gt;&lt;P&gt;789 | mach3 | 04:00 | 09:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the example, which I gave, when i am looping at itab1 before the control each at end of fun name,&lt;/P&gt;&lt;P&gt;itab3 shd contain&lt;/P&gt;&lt;P&gt;123 | mach1 | 07:00 | 08:00&lt;/P&gt;&lt;P&gt;123 | mach1 | 08:00 | 09:00&lt;/P&gt;&lt;P&gt;123 | mach2 | 06:00 | 08:00&lt;/P&gt;&lt;P&gt;456 | mach2 | 24:00 | 08:00&lt;/P&gt;&lt;P&gt;456 | mach2 | 07:00 | 12:00&lt;/P&gt;&lt;P&gt;since the machines 123,456 have same fun name FM1.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Aditya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 15:03:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683775#M887041</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T15:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: help needed on performance improvement avoiding nested loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683776#M887042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;no such thing as "for all entries" for internal tables. However if your itab2 is declared as a sorted table with non-unique key machine, looping through it for the matching machine from itab1 should not be a performance pooper.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;you could also loop at itab2, and at end of machine you read the corresponding entry of itab1 to find the function to be called. itab1 should also be declared as sorted table with key machine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 15:12:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683776#M887042</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-04-08T15:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: help needed on performance improvement avoiding nested loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683777#M887043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the FOR ALL ENTRIES is nothing very special, for internal tables it is not necessary, because a loop and read inside the loop can be&lt;/P&gt;&lt;P&gt;very fast, there is no room for improvement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As the FOR ALL ENTRIES will not work if there is no suitable index, so the read will not work if it can not faciliate a binary search&lt;/P&gt;&lt;P&gt;(either by a sorted table or by sorting the standard table and using binary search).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nested loops are unavoidable and that is fine. There are is a lot of coding of nested loops with performance bugs, but these bugs are avoidable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 16:48:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683777#M887043</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T16:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: help needed on performance improvement avoiding nested loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683778#M887044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for all of your help. I wanted to find out if I can avoid nested loops. As per your suggestion, I am using loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sunny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2008 17:30:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683778#M887044</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-08T17:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: help needed on performance improvement avoiding nested loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683779#M887045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suny,&lt;/P&gt;&lt;P&gt;Best way is use parallel cursors technique. here is a sample code to implement.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;please reward me if useful and close ticket.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&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;&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;P&gt;&lt;/P&gt;&lt;P&gt;if you have any issues to sort both tables with same key you can modify above algorithm slightly to suite your requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab2 into wa2 with key field1 = itab1-field1 binary search.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;I = sy-tabix.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB2 INTO WA2 FROM I.&lt;/P&gt;&lt;P&gt;    IF WA2-field1 &amp;lt;&amp;gt; WA1-field1.&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;endif.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2008 05:53:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683779#M887045</guid>
      <dc:creator>harishaginati</dc:creator>
      <dc:date>2008-04-09T05:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: help needed on performance improvement avoiding nested loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683780#M887046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sunny,&lt;/P&gt;&lt;P&gt;                As said by Harish parallel cursor method is best way to increase the performance. if it is compulsory to use nested loops, then we need to go for &lt;STRONG&gt;PARALLEL CURSOR METHOD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;this is very efficient method. This decreases the execution time and increases the performance.&lt;/P&gt;&lt;P&gt;here is a sample code for &lt;STRONG&gt;PARALLEL CURSOR METHOD&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nested Loops &amp;#150; This is one of the fear factors for all the ABAP developers as this consumes lot of program execution time. If the number of entries in the internal tables is huge, then the situation would be too worse. The solution for this is to use parallel cursor method whenever there is a need for Nested Loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Program using Normal Nested Loop:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT  ZNORMAL_NESTEDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES:&lt;/P&gt;&lt;P&gt;  likp,&lt;/P&gt;&lt;P&gt;  lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;  t_likp  type table of likp,&lt;/P&gt;&lt;P&gt;  t_lips  type TABLE OF lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;  W_RUNTIME1 TYPE I,&lt;/P&gt;&lt;P&gt;  W_RUNTIME2 TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;  from likp&lt;/P&gt;&lt;P&gt;  into table t_likp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;  from lips&lt;/P&gt;&lt;P&gt;  into table t_lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;get RUN TIME FIELD w_runtime1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_likp into likp.&lt;/P&gt;&lt;P&gt;  loop at t_lips into lips where vbeln eq likp-vbeln.&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;get RUN TIME FIELD w_runtime2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;w_runtime2 = w_runtime2 - w_runtime1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write w_runtime2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Nested Loop using Parallel Cursor:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT  zparallel_cursor2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES:&lt;/P&gt;&lt;P&gt;  likp,&lt;/P&gt;&lt;P&gt;  lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;  t_likp  TYPE TABLE OF likp,&lt;/P&gt;&lt;P&gt;  t_lips  TYPE TABLE OF lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;  w_runtime1 TYPE i,&lt;/P&gt;&lt;P&gt;  w_runtime2 TYPE i,&lt;/P&gt;&lt;P&gt;  w_index LIKE sy-index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;  SELECT *&lt;/P&gt;&lt;P&gt;    FROM likp&lt;/P&gt;&lt;P&gt;    INTO TABLE t_likp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT *&lt;/P&gt;&lt;P&gt;    FROM lips&lt;/P&gt;&lt;P&gt;    INTO TABLE t_lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  GET RUN TIME FIELD w_runtime1.&lt;/P&gt;&lt;P&gt;  SORT t_likp BY vbeln.&lt;/P&gt;&lt;P&gt;  SORT t_lips BY vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT t_likp INTO likp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    LOOP AT t_lips INTO lips FROM w_index.&lt;/P&gt;&lt;P&gt;      IF likp-vbeln NE lips-vbeln.&lt;/P&gt;&lt;P&gt;        w_index = sy-tabix.&lt;/P&gt;&lt;P&gt;        EXIT.&lt;/P&gt;&lt;P&gt;      ENDIF.&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;  GET RUN TIME FIELD w_runtime2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  w_runtime2 = w_runtime2 - w_runtime1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WRITE w_runtime2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Analysis report&lt;/STRONG&gt;: Runtime in microseconds:  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Iteration No&lt;/U&gt; ....._Normal Nest Loop_ ..... &lt;U&gt;Using Parallel Cursor&lt;/U&gt; &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;1 .......................  34,796,147 ...................  63,829 &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;2  .........................38,534,583  ................... 56,894 &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;3  .........................34,103,426  ................... 50,510 &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;u can check this site for more details&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.saptechnical.com/Tutorials/ABAP/ParallelCursor.htm" target="test_blank"&gt;http://www.saptechnical.com/Tutorials/ABAP/ParallelCursor.htm&lt;/A&gt;&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>Wed, 09 Apr 2008 12:20:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683780#M887046</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-09T12:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: help needed on performance improvement avoiding nested loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683781#M887047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everybody,&lt;/P&gt;&lt;P&gt;Thank you very much for your help. I found another way without using nested loop.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My input is&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;itab1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;machine | function name&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;123 | FM1 &lt;/P&gt;&lt;P&gt;456 | FM1 &lt;/P&gt;&lt;P&gt;789 | FM2 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;itab2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;machine | m/c description | start time | stop time |.....|.....|...&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;123 | mach1 | 07:00 | 08:00&lt;/P&gt;&lt;P&gt;123 | mach1 | 08:00 | 09:00&lt;/P&gt;&lt;P&gt;123 | mach2 | 06:00 | 08:00&lt;/P&gt;&lt;P&gt;456 | mach2 | 24:00 | 08:00&lt;/P&gt;&lt;P&gt;456 | mach2 | 07:00 | 12:00&lt;/P&gt;&lt;P&gt;789 | mach3 | 04:00 | 09:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Output&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In the example, which I gave, when i am looping at itab1 before the control each "at end of fun_name" event, I need to get all records from itab2 for the machines which have same function name in the itab1. In the above example machines 123 and 456 have same fun-name in itab1, so i got all the records from itab2 for which mach no is 123,456 into itab3.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;itab3&lt;/STRONG&gt; shd contain&lt;/P&gt;&lt;P&gt;123 | mach1 | 07:00 | 08:00&lt;/P&gt;&lt;P&gt;123 | mach1 | 08:00 | 09:00&lt;/P&gt;&lt;P&gt;123 | mach2 | 06:00 | 08:00&lt;/P&gt;&lt;P&gt;456 | mach2 | 24:00 | 08:00&lt;/P&gt;&lt;P&gt;456 | mach2 | 07:00 | 12:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My logic&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;ranges: r_mchno for ztable-mach_num..&lt;/P&gt;&lt;P&gt;loop at itab1 into wa&lt;/P&gt;&lt;P&gt;r_mchno-sign = 'I'&lt;/P&gt;&lt;P&gt;r_mchno-option = 'EQ'&lt;/P&gt;&lt;P&gt;r_mchno-low = wa-mchno.&lt;/P&gt;&lt;P&gt;append r_mchno.&lt;/P&gt;&lt;P&gt;at end of 'function_name'.&lt;/P&gt;&lt;P&gt;itab3 = itab2.&lt;/P&gt;&lt;P&gt;delete itab3 where machno not in r_mchno. " now i have only records which are having same fun name.&lt;/P&gt;&lt;P&gt;call wa-funciton_name&lt;/P&gt;&lt;P&gt;exporting&lt;/P&gt;&lt;P&gt; tab = itab3&lt;/P&gt;&lt;P&gt;clear r_mchno.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Main concept is I am copying the whole itab2 into itab3 and then i am deleting the unwanted records from itab3 based on the r_mchno (ranges). I mean I am deleting all the records from itab3 which are not in the r_mchno. In this way I avoided loop over itab2 inside loop over itab1 (avoiding nested loops).&lt;/P&gt;&lt;P&gt;Sunny&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Sunny on Apr 9, 2008 12:15 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2008 17:11:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-needed-on-performance-improvement-avoiding-nested-loops/m-p/3683781#M887047</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-09T17:11:44Z</dc:date>
    </item>
  </channel>
</rss>

