<?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: Nested Loops in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457630#M1250538</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;Why don't you combine the two SELECT statements? Without understanding what you intend to achieve the following coding might be close to what you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT COSTCENTER /BIC/ZMR2K_OWR FROM /bi0/pcostcenter 
  INTO CORRESPONDING FIELDS OF TABLE lt_pcc2
  WHERE ( /bic/zmr2krc1 NE '' ) 
  AND ( /BIC/ZMR2K_OWR = &amp;lt;Variable&amp;gt; ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Apr 2009 17:45:30 GMT</pubDate>
    <dc:creator>uwe_schieferstein</dc:creator>
    <dc:date>2009-04-16T17:45:30Z</dc:date>
    <item>
      <title>Nested Loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457629#M1250537</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;                Can you pl give me different ways to improve the performance of the following code. Currently it's taking long time. Want to reduce the processing time. Costcenter table contains more than 300000 records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from /bi0/pcostcenter into table it_pcc&lt;/P&gt;&lt;P&gt;             where /bic/zmr2krc1 ne ''.&lt;/P&gt;&lt;P&gt;select * from /bi0/pcostcenter into table it_pcc1&lt;/P&gt;&lt;P&gt;            where /BIC/ZMR2K_OWR = &amp;lt;Variable&amp;gt;.&lt;/P&gt;&lt;P&gt;sort it_pcc1 by costcenter.&lt;/P&gt;&lt;P&gt;delete adjacent duplicates from it_pcc1 comparing costcenter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort it_pcc.&lt;/P&gt;&lt;P&gt;loop at it_pcc1.&lt;/P&gt;&lt;P&gt;  loop at it_pcc where&lt;/P&gt;&lt;P&gt;                 ( /bic/zmr2krc1 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc2 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc3 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc4 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc5 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc6 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc7 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc8 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc9 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc10 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc11 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc12 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc13 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc14 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc15 = it_pcc1-costcenter ).&lt;/P&gt;&lt;P&gt;    it_pcc2-costcenter = it_pcc-costcenter.&lt;/P&gt;&lt;P&gt;    it_pcc2-/bic/zmr2k_owr =  it_pcc1-/bic/zmr2k_owr.&lt;/P&gt;&lt;P&gt;    append it_pcc2.&lt;/P&gt;&lt;P&gt;    clear it_pcc2.&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;Thanks &amp;amp; Regards ::&lt;/P&gt;&lt;P&gt;Balaji T&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2009 17:29:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457629#M1250537</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-16T17:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457630#M1250538</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;Why don't you combine the two SELECT statements? Without understanding what you intend to achieve the following coding might be close to what you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT COSTCENTER /BIC/ZMR2K_OWR FROM /bi0/pcostcenter 
  INTO CORRESPONDING FIELDS OF TABLE lt_pcc2
  WHERE ( /bic/zmr2krc1 NE '' ) 
  AND ( /BIC/ZMR2K_OWR = &amp;lt;Variable&amp;gt; ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2009 17:45:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457630#M1250538</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2009-04-16T17:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457631#M1250539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uwe,&lt;/P&gt;&lt;P&gt;           Following is my requirement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First SQL statement fetches first set of records into it_pcc based on given condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT COSTCENTER /BIC/ZMR2K_OWR FROM /bi0/pcostcenter &lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF TABLE lt_pcc2&lt;/P&gt;&lt;P&gt;  WHERE ( /bic/zmr2krc1 NE '' ) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second SQL statement fetches second set of records into it_pcc1 based on given condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT COSTCENTER /BIC/ZMR2K_OWR FROM /bi0/pcostcenter &lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF TABLE lt_pcc2&lt;/P&gt;&lt;P&gt;  WHERE  /BIC/ZMR2K_OWR = &amp;lt;Variable&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After Fetching 2 sets, I need to do following processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For each record in 2nd Set of records I need to find all the matching records of the 1st Set of records which satisfies the following condition. So your suggestion will not work in my case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_pcc where&lt;/P&gt;&lt;P&gt;                 ( /bic/zmr2krc1 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc2 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc3 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc4 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc5 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc6 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc7 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc8 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc9 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc10 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc11 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc12 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc13 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc14 = it_pcc1-costcenter or&lt;/P&gt;&lt;P&gt;                   /bic/zmr2krc15 = it_pcc1-costcenter ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards ::&lt;/P&gt;&lt;P&gt;Balaji T&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2009 17:54:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457631#M1250539</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-16T17:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457632#M1250540</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;PRE&gt;&lt;CODE&gt;

SELECT COSTCENTER /BIC/ZMR2K_OWR FROM /bi0/pcostcenter 
  INTO CORRESPONDING FIELDS OF TABLE lt_pcc2
 WHERE  /BIC/ZMR2K_OWR = &amp;lt;Variable&amp;gt;.

SELECT COSTCENTER /BIC/ZMR2K_OWR FROM /bi0/pcostcenter 
INTO CORRESPONDING FIELDS OF TABLE lt_pcc1
for all entries in IT_PCC1
WHERE  /bic/zmr2krc1 NE '' 
and   ( /bic/zmr2krc1 = it_pcc1-costcenter or
          /bic/zmr2krc2 = it_pcc1-costcenter or
         /bic/zmr2krc3 = it_pcc1-costcenter or
         /bic/zmr2krc4 = it_pcc1-costcenter or
         /bic/zmr2krc5 = it_pcc1-costcenter or
         /bic/zmr2krc6 = it_pcc1-costcenter or
         /bic/zmr2krc7 = it_pcc1-costcenter or
         /bic/zmr2krc8 = it_pcc1-costcenter or
         /bic/zmr2krc9 = it_pcc1-costcenter or
        /bic/zmr2krc10 = it_pcc1-costcenter or
        /bic/zmr2krc11 = it_pcc1-costcenter or
        /bic/zmr2krc12 = it_pcc1-costcenter or
        /bic/zmr2krc13 = it_pcc1-costcenter or
        /bic/zmr2krc14 = it_pcc1-costcenter or
         /bic/zmr2krc15 = it_pcc1-costcenter ).

sort it_pcc1 by costcenter.
delete adjacent duplicates from it_pcc1 comparing costcenter.

sort it_pcc.
loop at it_pcc1.
loop at it_pcc .
it_pcc2-/bic/zmr2k_owr = it_pcc1-/bic/zmr2k_owr.
append it_pcc2.
clear it_pcc2.
endloop.
endloop.



&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prabhudas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Prabhu Das on Apr 16, 2009 11:32 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Prabhu Das on Apr 16, 2009 11:34 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2009 18:01:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457632#M1250540</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-16T18:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457633#M1250541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not very elegant, but it should work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT it_pcc1 BY costcenter.
LOOP AT it_pcc.
  READ TABLE it_pcc1
    WITH KEY costcenter = it_pcc-/bic/zmr2krc1
    BINARY SEARCH.
  IF sy-subrc NE 0.
    READ TABLE it_pcc1
      WITH KEY costcenter = it_pcc-/bic/zmr2krc1
      BINARY SEARCH.
    IF sy-subrc NE 0.
*      ... and so on for all 15 entries.
    ENDIF.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2009 18:02:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457633#M1250541</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-16T18:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457634#M1250542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;           Thank you for the idea of looping on first set of records and reading 2nd set of records. That worked. But I changed the code little bit. Following is the code. I'm awarding points to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;l_ctr = 0.
  DO 15 TIMES.
     l_ctr = l_ctr + 1.
     l_cnt = l_ctr.
     CONCATENATE 'it_pcc-/bic/zmr2krc' l_cnt into l_field.
     ASSIGN COMPONENT l_field OF STRUCTURE it_pcc TO &amp;lt;fld_name&amp;gt;.
     ASSIGN (l_field) to &amp;lt;fld_name&amp;gt;.
     READ TABLE it_pcc1
          WITH KEY costcenter = &amp;lt;fld_name&amp;gt;
          BINARY SEARCH.
     IF sy-subrc EQ 0.
        it_pcc2-costcenter = it_pcc-costcenter.
        it_pcc2-/bic/zmr2k_owr =  it_pcc-/bic/zmr2k_owr.
        append it_pcc2.
        clear it_pcc2.
        exit.
     ENDIF.
  ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards ::&lt;/P&gt;&lt;P&gt;Balaji T&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2009 18:59:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457634#M1250542</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-16T18:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457635#M1250543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad it helped, but don't forget - the others helped as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2009 19:20:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457635#M1250543</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-16T19:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457636#M1250544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;         Thanks to all of you who helped me in resolving the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards ::&lt;/P&gt;&lt;P&gt;Balaji T&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2009 19:54:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457636#M1250544</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-16T19:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457637#M1250545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Balaji  - what I really meant that the way to express thanks in the forum is by assigning po(i)nts to answers &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2009 20:32:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457637#M1250545</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-16T20:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Loops</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457638#M1250546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes Rob. I got that. Just missed that part last time. Thanks for reminding that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards ::&lt;/P&gt;&lt;P&gt;Balaji T&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2009 22:22:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-loops/m-p/5457638#M1250546</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-16T22:22:53Z</dc:date>
    </item>
  </channel>
</rss>

