<?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: Performance on select join vbap/vbak/vbep in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887325#M52735</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Coppalle,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sometimes you need to have a bit more confidence.&lt;/P&gt;&lt;P&gt;Your WHERE-clause checks VBELN for all tables, but in an inner join they are already checked if VBELN is used in the relation.&lt;/P&gt;&lt;P&gt;To check number fields &amp;lt;&amp;gt; 0 &amp;lt;u&amp;gt;AND&amp;lt;/u&amp;gt; also &amp;lt;&amp;gt; '0' is not required. Use either one (what you find easy to use), allthough &amp;lt;&amp;gt; 0 is slightly faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since many records are in your tables, consider the following program detail.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: p_tvbapcache_buf LIKE p_tvbapcache OCCURS 0,
      w_tvbapcache_buf LIKE p_tvbapcache.
SELECT ap~vbeln ap~posnr ap~matnr ap~matkl ap~prodh ap~arktx
       ap~netwr ap~kzwi3 ap~kzwi1 ap~mwsbp ap~vrkme ap~brgew
       ep~bmeng ep~wmeng ep~edatu
  INTO CORRESPONDING FIELDS OF TABLE p_tvbapcache_buf
  FROM vbap AS ap PACKAGE SIZE 10000
 INNER JOIN vbep AS ep
    ON ap~vbeln = ep~vbeln
   AND ap~posnr = ep~posnr
 INNER JOIN vbak AS ak
    ON ak~vbeln = ep~vbeln
   AND ap~vbeln = ak~vbeln
 WHERE ak~auart IN canal
   AND ak~faksk &amp;lt;&amp;gt; 'Z3'.
  LOOP AT p_tvbapcache_buf INTO w_tvbapcache_buf.
    CHECK: vbeln NOT LIKE '0005%',
           prodh IN nomencla,
           matnr IN numero,
           netwr &amp;lt;&amp;gt; 0,
           kzwi1 &amp;lt;&amp;gt; 0,
           edatu IN date,
           wmeng &amp;lt;&amp;gt; 0, 
           bmeng &amp;lt;&amp;gt; 0.
    APPEND w_tvbapcache_buf TO p_tvbapcache.
  ENDLOOP.
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And as last suggestion: I see that you use a lot of 'NEGATIVE' selections (this is selection by exclusion). In the database world this is a very bad way of selecting data, because it will not follow any key in a table. In my opinion you try and find a way of using at least a selection that can use a key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this gives you some directions,&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rob.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 May 2005 07:05:00 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-05-26T07:05:00Z</dc:date>
    <item>
      <title>Performance on select join vbap/vbak/vbep</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887322#M52732</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;I would like to know how improve the performance (time-reponse) of my select :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;ap&lt;SUB&gt;matkl  ap&lt;/SUB&gt;prodh ap&lt;SUB&gt;matnr  ap&lt;/SUB&gt;arktx  ap&lt;SUB&gt;vbeln ap&lt;/SUB&gt;posnr  ap&lt;SUB&gt;netwr  ap&lt;/SUB&gt;kzwi3  ap&lt;SUB&gt;kzwi1  ap&lt;/SUB&gt;mwsbp&lt;/P&gt;&lt;P&gt;ep&lt;SUB&gt;bmeng  ep&lt;/SUB&gt;wmeng  ep&lt;SUB&gt;edatu  ap&lt;/SUB&gt;vrkme  ap~brgew&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE p_tvbapcache&lt;/P&gt;&lt;P&gt;FROM vbap AS ap &lt;/P&gt;&lt;P&gt;INNER JOIN vbep AS ep ON  ap&lt;SUB&gt;vbeln = ep&lt;/SUB&gt;vbeln AND ap&lt;SUB&gt;posnr = ep&lt;/SUB&gt;posnr&lt;/P&gt;&lt;P&gt;INNER JOIN vbak AS ak ON  ak&lt;SUB&gt;vbeln = ep&lt;/SUB&gt;vbeln AND ap&lt;SUB&gt;vbeln = ak&lt;/SUB&gt;vbeln&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE ak~vbeln NOT LIKE '0005%' &lt;/P&gt;&lt;P&gt;AND ep~vbeln NOT LIKE '0005%' &lt;/P&gt;&lt;P&gt;AND ap~vbeln NOT LIKE '0005%' &lt;/P&gt;&lt;P&gt;AND ep~edatu IN date&lt;/P&gt;&lt;P&gt;AND ap~prodh IN nomencla&lt;/P&gt;&lt;P&gt;AND ak~auart IN canal&lt;/P&gt;&lt;P&gt;AND ap~matnr IN numero&lt;/P&gt;&lt;P&gt;AND ap&lt;SUB&gt;netwr &amp;lt;&amp;gt; 0 AND ap&lt;/SUB&gt;netwr &amp;lt;&amp;gt; '0'&lt;/P&gt;&lt;P&gt;AND ep&lt;SUB&gt;wmeng &amp;lt;&amp;gt; 0 AND ep&lt;/SUB&gt;wmeng &amp;lt;&amp;gt; '0' &lt;/P&gt;&lt;P&gt;AND ep&lt;SUB&gt;bmeng &amp;lt;&amp;gt; 0 AND ep&lt;/SUB&gt;bmeng &amp;lt;&amp;gt; '0' &lt;/P&gt;&lt;P&gt;AND ap&lt;SUB&gt;kzwi1 &amp;lt;&amp;gt; 0 AND ap&lt;/SUB&gt;kzwi1 &amp;lt;&amp;gt; '0' &lt;/P&gt;&lt;P&gt;AND ak~faksk &amp;lt;&amp;gt; 'Z3'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The performance are very very very poor... &lt;/P&gt;&lt;P&gt;For information, there are 18.329.040 entries in VBAP table; VBAK : 485.437 entries ; VBEP : 18.304.173 entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks for yours ideas,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 May 2005 15:39:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887322#M52732</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-05-25T15:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Performance on select join vbap/vbak/vbep</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887323#M52733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Coppalle:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Couple of things:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. You can split the SQL into 2 different ones. The first one can be executed against view VIVEDA in which the WHERE conditions can cover VBAP and VBAK related checked. From the selected records retrieved, run the records against the remaining table i.e. VBEP to get the rows that you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Try replacing &amp;lt;&amp;gt; 0 and &amp;lt;&amp;gt; '0' conditions with &amp;gt; 0 option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Statements like 'NOT LIKE' and 'IN' are costly in terms of execution time - and especially when you are joining 3 tables in one shot, it is not a surprise that the execution time is very slow. As I mentioned in point 1, try to retrieve details first using the view so that you can perform the filterning of records from internal table etc fast rather than at the time of retrieving records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chetan Singh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 May 2005 16:10:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887323#M52733</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-05-25T16:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Performance on select join vbap/vbak/vbep</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887324#M52734</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;I suggest to select records from VBAK first and then use for all entries(vbeln) in VBAP for that first internal table and then use for all entries in VBEP(vbeln and posnr) for the second internal table .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 May 2005 06:10:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887324#M52734</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2005-05-26T06:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Performance on select join vbap/vbak/vbep</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887325#M52735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Coppalle,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sometimes you need to have a bit more confidence.&lt;/P&gt;&lt;P&gt;Your WHERE-clause checks VBELN for all tables, but in an inner join they are already checked if VBELN is used in the relation.&lt;/P&gt;&lt;P&gt;To check number fields &amp;lt;&amp;gt; 0 &amp;lt;u&amp;gt;AND&amp;lt;/u&amp;gt; also &amp;lt;&amp;gt; '0' is not required. Use either one (what you find easy to use), allthough &amp;lt;&amp;gt; 0 is slightly faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since many records are in your tables, consider the following program detail.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: p_tvbapcache_buf LIKE p_tvbapcache OCCURS 0,
      w_tvbapcache_buf LIKE p_tvbapcache.
SELECT ap~vbeln ap~posnr ap~matnr ap~matkl ap~prodh ap~arktx
       ap~netwr ap~kzwi3 ap~kzwi1 ap~mwsbp ap~vrkme ap~brgew
       ep~bmeng ep~wmeng ep~edatu
  INTO CORRESPONDING FIELDS OF TABLE p_tvbapcache_buf
  FROM vbap AS ap PACKAGE SIZE 10000
 INNER JOIN vbep AS ep
    ON ap~vbeln = ep~vbeln
   AND ap~posnr = ep~posnr
 INNER JOIN vbak AS ak
    ON ak~vbeln = ep~vbeln
   AND ap~vbeln = ak~vbeln
 WHERE ak~auart IN canal
   AND ak~faksk &amp;lt;&amp;gt; 'Z3'.
  LOOP AT p_tvbapcache_buf INTO w_tvbapcache_buf.
    CHECK: vbeln NOT LIKE '0005%',
           prodh IN nomencla,
           matnr IN numero,
           netwr &amp;lt;&amp;gt; 0,
           kzwi1 &amp;lt;&amp;gt; 0,
           edatu IN date,
           wmeng &amp;lt;&amp;gt; 0, 
           bmeng &amp;lt;&amp;gt; 0.
    APPEND w_tvbapcache_buf TO p_tvbapcache.
  ENDLOOP.
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And as last suggestion: I see that you use a lot of 'NEGATIVE' selections (this is selection by exclusion). In the database world this is a very bad way of selecting data, because it will not follow any key in a table. In my opinion you try and find a way of using at least a selection that can use a key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this gives you some directions,&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rob.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 May 2005 07:05:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887325#M52735</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-05-26T07:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Performance on select join vbap/vbak/vbep</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887326#M52736</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;Instead of using the number range of the document, (WHERE ak~vbeln NOT LIKE '0005%'...) &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;- try the use the VBAK-AUART to include or exclude a kind of documents.&lt;/P&gt;&lt;P&gt;- or try to use VBAK-TRVOG to include/exclude a kind of documents&lt;/P&gt;&lt;P&gt;- or build a range - see help on range statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;JG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 May 2005 07:18:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887326#M52736</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-05-26T07:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Performance on select join vbap/vbak/vbep</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887327#M52737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Me again:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- if the material number is mandatory in your selection screen... use table VAPMA first to retrieve documents and you as well can use the field TRVOG to include/exclude a kind of documents...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 May 2005 07:22:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-on-select-join-vbap-vbak-vbep/m-p/887327#M52737</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-05-26T07:22:03Z</dc:date>
    </item>
  </channel>
</rss>

