<?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: avoiding loop within select statements in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533356#M850020</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;The loop which you are using is not WITHIN the select statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ie ... It is not executing within the select statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it should not cause any kind of performance issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What exactly is the problem which you are facing ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Mar 2008 12:25:24 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-10T12:25:24Z</dc:date>
    <item>
      <title>avoiding loop within select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533355#M850019</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;        Below i m providing my code where we are looping in between two select statements , but i dont want to use loop in between two select statements so can anyone give any other way of approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;code&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT a~vbeln&lt;/P&gt;&lt;P&gt;         a~erdat&lt;/P&gt;&lt;P&gt;         a~erzet&lt;/P&gt;&lt;P&gt;         a~auart&lt;/P&gt;&lt;P&gt;         b~posnr&lt;/P&gt;&lt;P&gt;         b~matnr&lt;/P&gt;&lt;P&gt;         b~kwmeng&lt;/P&gt;&lt;P&gt;         FROM vbak AS a INNER JOIN vbap AS b&lt;/P&gt;&lt;P&gt;         ON a&lt;SUB&gt;mandt = b&lt;/SUB&gt;mandt&lt;/P&gt;&lt;P&gt;         AND a&lt;SUB&gt;vbeln = b&lt;/SUB&gt;vbeln&lt;/P&gt;&lt;P&gt;         INTO TABLE it_orders.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*append lines of it_orders-vbeln to it_vbeln-vbeln.&lt;/P&gt;&lt;P&gt;*append lines of it_orders to it_vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT it_orders.&lt;/P&gt;&lt;P&gt;    CLEAR it_vbeln.&lt;/P&gt;&lt;P&gt;    it_vbeln-vbeln = it_orders-vbeln.&lt;/P&gt;&lt;P&gt;    APPEND it_vbeln.&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;  IF NOT it_vbeln[] IS INITIAL.&lt;/P&gt;&lt;P&gt;    SELECT objky&lt;/P&gt;&lt;P&gt;           kschl&lt;/P&gt;&lt;P&gt;           FROM nast&lt;/P&gt;&lt;P&gt;           INTO TABLE it_nast&lt;/P&gt;&lt;P&gt;           FOR ALL ENTRIES IN it_vbeln&lt;/P&gt;&lt;P&gt;           WHERE objky  = it_vbeln-vbeln.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/code&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;satish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2008 12:13:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533355#M850019</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-10T12:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding loop within select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533356#M850020</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;The loop which you are using is not WITHIN the select statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ie ... It is not executing within the select statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it should not cause any kind of performance issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What exactly is the problem which you are facing ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2008 12:25:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533356#M850020</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-10T12:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding loop within select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533357#M850021</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;SELECT a~vbeln&lt;/P&gt;&lt;P&gt;FROM vbak AS a INNER JOIN vbap AS b&lt;/P&gt;&lt;P&gt;ON a&lt;SUB&gt;mandt = b&lt;/SUB&gt;mandt&lt;/P&gt;&lt;P&gt;AND a&lt;SUB&gt;vbeln = b&lt;/SUB&gt;vbeln&lt;/P&gt;&lt;P&gt;INTO TABLE it_vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2008 12:30:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533357#M850021</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-10T12:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding loop within select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533358#M850022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Satish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  There is enough of your code missing that makes this a bit difficult to debug.  &lt;/P&gt;&lt;P&gt;      Like:&lt;/P&gt;&lt;P&gt;        Is this code being performed from somewhere else?&lt;/P&gt;&lt;P&gt;        How are the tables defined? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the tables are defined like this,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;  BEGIN OF vbeln_rec,&lt;/P&gt;&lt;P&gt;    vbeln      LIKE nast-objky,&lt;/P&gt;&lt;P&gt;  END OF vbeln_rec,&lt;/P&gt;&lt;P&gt;  it_vbeln LIKE vbeln_rec OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is possible, that you need to refresh the table like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**append lines of it_orders-vbeln to it_vbeln-vbeln.&lt;/P&gt;&lt;P&gt;**append lines of it_orders to it_vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;STRONG&gt;refresh: it_vbeln.&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT it_orders.&lt;/P&gt;&lt;P&gt;    CLEAR it_vbeln.&lt;/P&gt;&lt;P&gt;    it_vbeln-vbeln = it_orders-vbeln.&lt;/P&gt;&lt;P&gt;    APPEND it_vbeln.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Paul Chapman on Mar 10, 2008 1:35 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2008 12:33:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533358#M850022</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-10T12:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding loop within select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533359#M850023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT a~vbeln
       a~erdat
      a~erzet
      a~auart
      b~posnr
      b~matnr
      b~kwmeng
FROM vbak AS a INNER JOIN vbap AS b
ON a~mandt = b~mandt
AND a~vbeln = b~vbeln
INTO TABLE it_orders.

*append lines of it_orders-vbeln to it_vbeln-vbeln.
*append lines of it_orders to it_vbeln.

*LOOP AT it_orders.
*CLEAR it_vbeln.
*it_vbeln-vbeln = it_orders-vbeln.
*APPEND it_vbeln.
*ENDLOOP.
*
"Your final table is it_nast. 
"My doubt is why your filling it_vbeln in between???
"instead of  it_vbeln why can't you use it_orders???.

IF NOT it_orders[] IS INITIAL.
SELECT objky
             kschl
FROM nast
INTO TABLE it_nast
FOR ALL ENTRIES IN it_odrers
WHERE objky = it_orders-vbeln.
ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2008 12:44:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-loop-within-select-statements/m-p/3533359#M850023</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-10T12:44:00Z</dc:date>
    </item>
  </channel>
</rss>

