<?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 joining select statements-performance problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019105#M80701</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here two cases are there.Is it posiible to combine the two cases and make it one? I am using OR in the select statement, performance is very bad, i want to improve it.Is there any chance of avoiding that... &lt;/P&gt;&lt;P&gt;1. &lt;/P&gt;&lt;P&gt;select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1 &lt;/P&gt;&lt;P&gt;or vbelv = final_data-xblnr2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single vbeln from vbrk into tabvbrk-vbeln &lt;/P&gt;&lt;P&gt;where vbeln = itab-vbeln and fkart = 'RTS'. &lt;/P&gt;&lt;P&gt;if sy-subrc eq 0. &lt;/P&gt;&lt;P&gt;move tabvbrk-vbeln to final_data-vbeln1. &lt;/P&gt;&lt;P&gt;modify final_data. &lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;endselect. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. &lt;/P&gt;&lt;P&gt;select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1 &lt;/P&gt;&lt;P&gt;or vbelv = final_data-xblnr2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single vbeln from vbrk into tabvbrk-vbeln &lt;/P&gt;&lt;P&gt;where vbeln = itab-vbeln and fkart = 'ZTR'. &lt;/P&gt;&lt;P&gt;if sy-subrc eq 0. &lt;/P&gt;&lt;P&gt;move tabvbrk-vbeln to final_data-vbeln2. &lt;/P&gt;&lt;P&gt;modify final_data. &lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;endselect. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;fractal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Aug 2005 03:42:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-08-30T03:42:34Z</dc:date>
    <item>
      <title>joining select statements-performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019105#M80701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here two cases are there.Is it posiible to combine the two cases and make it one? I am using OR in the select statement, performance is very bad, i want to improve it.Is there any chance of avoiding that... &lt;/P&gt;&lt;P&gt;1. &lt;/P&gt;&lt;P&gt;select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1 &lt;/P&gt;&lt;P&gt;or vbelv = final_data-xblnr2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single vbeln from vbrk into tabvbrk-vbeln &lt;/P&gt;&lt;P&gt;where vbeln = itab-vbeln and fkart = 'RTS'. &lt;/P&gt;&lt;P&gt;if sy-subrc eq 0. &lt;/P&gt;&lt;P&gt;move tabvbrk-vbeln to final_data-vbeln1. &lt;/P&gt;&lt;P&gt;modify final_data. &lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;endselect. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. &lt;/P&gt;&lt;P&gt;select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1 &lt;/P&gt;&lt;P&gt;or vbelv = final_data-xblnr2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single vbeln from vbrk into tabvbrk-vbeln &lt;/P&gt;&lt;P&gt;where vbeln = itab-vbeln and fkart = 'ZTR'. &lt;/P&gt;&lt;P&gt;if sy-subrc eq 0. &lt;/P&gt;&lt;P&gt;move tabvbrk-vbeln to final_data-vbeln2. &lt;/P&gt;&lt;P&gt;modify final_data. &lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;endselect. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;fractal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2005 03:42:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019105#M80701</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-30T03:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: joining select statements-performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019106#M80702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. Instead of using or in where clause you can define Range for vbelv using RANGES statement. You have to populate the Ranges internal table with the two values of vbelv that you are using in the where clause. Then you can use the 'IN' option in where clause. This will improve performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Instead of Select Endselect you should use "select into table 'itab'". All data will then come into internal table 'itab'. You can then loop on this internal table 'itab' and include both select single statements in the loop, one below the other. This will further improve performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Sudhir Bhate&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2005 04:03:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019106#M80702</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-30T04:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: joining select statements-performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019107#M80703</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;Use Ranges for this purpose:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RANGES:
r_fkart for vbrk-fkart.

r_fkart-low = 'RTS'.
r_fkart-sign = 'I'.
r_fkart-option = 'EQ'.
append r_fkart.

Similarly do for 'ZTR'.


select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1 
or vbelv = final_data-xblnr2. 

select single vbeln from vbrk into tabvbrk-vbeln 
where vbeln = itab-vbeln and fkart in r_fkart.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Anjali&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2005 04:29:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019107#M80703</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-30T04:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: joining select statements-performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019108#M80704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Instead of SELECTing single from VBRK for all items (You need only header record), you can SELECT data from VBFA into internal table and then based on that internal table SELECT data from VBRK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In other words, avoid nested SELECT statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2005 04:32:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019108#M80704</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-30T04:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: joining select statements-performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019109#M80705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The first main thing is dont use select... endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1 
or vbelv = final_data-xblnr2.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can use&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select vbeln from vbfa into 
 corresponding fields of table itab
 for all entries in final_data
 where vbelv = final_data-xblnr1 
 or   vbelv = final_data-xblnr2.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of this&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select single vbeln from vbrk into tabvbrk-vbeln 
where vbeln = itab-vbeln and fkart = 'RTS'. 
if sy-subrc eq 0. 
move tabvbrk-vbeln to final_data-vbeln1. 
modify final_data. 
endif. 
endselect.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select vbeln from vbrk 
        appending table final_data 
        where vbeln = itab-vbeln 
        and fkart = 'RTS'. 
if sy-subrc eq 0. 

endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try like this.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly reward points for the answer which helped u and helped to solve the problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2005 04:33:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019109#M80705</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-30T04:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: joining select statements-performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019110#M80706</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;First avoid select end select statement, for that define one internal table for the first select, check the code below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of itab1 occurs 0,&lt;/P&gt;&lt;P&gt;         vbeln like vbak-vbeln,&lt;/P&gt;&lt;P&gt;       end of itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of itab2 occurs 0,&lt;/P&gt;&lt;P&gt;         vbeln like vbak-vbeln,&lt;/P&gt;&lt;P&gt;       end of itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select vbeln from vbfa into table itab1where vbelv = final_data-xblnr1 or vbelv = final_data-xblnr2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not itab1[] is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      select vbeln from vbrk into table itab2 &lt;/P&gt;&lt;P&gt;      for all entriels in itab1&lt;/P&gt;&lt;P&gt;      where vbeln = itab-vbeln and fkart = 'RTS'.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Sasi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2005 05:48:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019110#M80706</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-30T05:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: joining select statements-performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019111#M80707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Use IN instead of OR.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select vbeln from vbfa into itab-vbeln&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;where vbelv IN ( final_data-xblnr1, vbelv = final_data-xblnr2 ).&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single vbeln from vbrk into tabvbrk-vbeln &lt;/P&gt;&lt;P&gt;where vbeln = itab-vbeln and fkart = 'RTS'. &lt;/P&gt;&lt;P&gt;if sy-subrc eq 0. &lt;/P&gt;&lt;P&gt;move tabvbrk-vbeln to final_data-vbeln1. &lt;/P&gt;&lt;P&gt;modify final_data. &lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2005 13:35:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-select-statements-performance-problem/m-p/1019111#M80707</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-30T13:35:22Z</dc:date>
    </item>
  </channel>
</rss>

