<?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 performance issue in select query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-query/m-p/6549804#M1429359</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi gurus.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is my code......have performance issue......in following steps...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. there are 6 select query with tables,&lt;/P&gt;&lt;P&gt;   VBAK&lt;/P&gt;&lt;P&gt;   VBAP&lt;/P&gt;&lt;P&gt;   VBRP&lt;/P&gt;&lt;P&gt;   VBEP&lt;/P&gt;&lt;P&gt;   zsd_lips_vttk &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. LOOP AT T_VBAP AND FILL ALL DATA TO T_FINAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIME CONSUMING STEPS ARE....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DATA COMING IN T_VBRP TABLE.&lt;/P&gt;&lt;P&gt;    DATA COMING IN T_zsd_lips_vttk TABLE.&lt;/P&gt;&lt;P&gt;    DATA COMING IN it_MKPF_MSEG TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    TIME CONSUMING IN LOOP ALSO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;rahul&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Jan 29, 2010 8:57 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Jan 2010 05:08:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-01-29T05:08:06Z</dc:date>
    <item>
      <title>performance issue in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-query/m-p/6549804#M1429359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi gurus.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is my code......have performance issue......in following steps...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. there are 6 select query with tables,&lt;/P&gt;&lt;P&gt;   VBAK&lt;/P&gt;&lt;P&gt;   VBAP&lt;/P&gt;&lt;P&gt;   VBRP&lt;/P&gt;&lt;P&gt;   VBEP&lt;/P&gt;&lt;P&gt;   zsd_lips_vttk &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. LOOP AT T_VBAP AND FILL ALL DATA TO T_FINAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIME CONSUMING STEPS ARE....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DATA COMING IN T_VBRP TABLE.&lt;/P&gt;&lt;P&gt;    DATA COMING IN T_zsd_lips_vttk TABLE.&lt;/P&gt;&lt;P&gt;    DATA COMING IN it_MKPF_MSEG TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    TIME CONSUMING IN LOOP ALSO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;rahul&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Jan 29, 2010 8:57 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2010 05:08:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-query/m-p/6549804#M1429359</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-29T05:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: performance issue in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-query/m-p/6549805#M1429360</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;1.Avoid CORRESPONDING FIELDS OF TABLE .&lt;/P&gt;&lt;P&gt;2.Before READ u sort the internal table with key.&lt;/P&gt;&lt;P&gt;3.Joining two tables use Views&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2010 05:18:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-query/m-p/6549805#M1429360</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-29T05:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: performance issue in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-query/m-p/6549806#M1429361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Learn how to use Code !!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT mblnr budat 
          FROM mkpf 
          INTO TABLE t_mkpf 
          WHERE budat IN s_budat. * * * * 

IF NOT t_mkpf[] IS INITIAL. * 
     SELECT mblnr MJAHR mat_kdauf mat_kdpos menge 
              FROM mseg 
              INTO TABLE t_mseg * 
             FOR ALL ENTRIES IN t_mkpf[] * 
             WHERE mblnr = t_mkpf-mblnr 
          and * MJAHR in s_budat. * 
ENDIF. 
        select mkpf_mblnr budat MJAHR mat_kdauf mat_kdpos menge 
        from Z_MKPF_MSEG 
         into corresponding fields of table it_MKPF_MSEG 
       where budat in s_budat and MJAHR in s_budat. 

delete ADJACENT DUPLICATES FROM it_MKPF_MSEG 
             COMPARING ALL FIELDS. * 

IF NOT s_budat IS INITIAL. * 
LOOP AT t_vbap INTO w_vbap. * 
      READ TABLE t_mseg WITH KEY mat_kdauf = w_vbap-vbeln mat_kdpos = w_vbap-posnr. 

 IF sy-subrc EQ 0. * 
     DELETE t_vbap WHERE vbeln = w_vbap-vbeln AND posnr = w_vbap-posnr. * 
ENDIF. * 
ENDLOOP. * ENDIF. 

IF NOT s_budat IS INITIAL. 
 LOOP AT t_vbap INTO w_vbap. 
      READ TABLE it_MKPF_MSEG WITH KEY mat_kdauf = w_vbap-vbeln mat_kdpos = w_vbap-posnr. 
  IF sy-subrc EQ 0.  
   DELETE t_vbap WHERE vbeln = w_vbap-vbeln AND posnr = w_vbap-posnr. 
  ENDIF. 
 ENDLOOP. 
ENDIF. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The INTO CORRESPONDING is o.k., no problem&lt;/P&gt;&lt;P&gt;A JOIN and a view are identical, no performance effect.&lt;/P&gt;&lt;P&gt;Use sorted tables or sort standard tables and use binary search !!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But your problems are different:&lt;/P&gt;&lt;P&gt;1.   The DELETE ADJACENT DUPLICATES requires the table to be sorted in the same order !!!&lt;/P&gt;&lt;P&gt;2.   The 'IF NOT s_budat IS INITIAL. should could once around the whole coding, already the first SELECT does not make sense! 3.   Performance is spent in the DELETE WHERE use DELETE with index.&lt;/P&gt;&lt;P&gt;4.   Usually I would recommend the positive logic:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2010 09:54:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-query/m-p/6549806#M1429361</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-29T09:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: performance issue in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-query/m-p/6549807#M1429362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
 IF sy-subrc EQ 0. * 
     sort t_vbap by vbeln posnr.
     sort t_mseg by kdauf kdpos.
     sort t_mkpf_mseg by kdauf kdpos.
     DELETE t_vbap WHERE vbeln = w_vbap-vbeln AND posnr = w_vbap-posnr. * 

     LOOP AT t_vbap INTO w_vbap. * 
          READ TABLE t_mseg 
                    WITH KEY mat_kdauf = w_vbap-vbeln mat_kdpos = w_vbap-posnr
                    BINARY SEARCH. 

          IF sy-subrc &amp;lt;&amp;gt; 0.  
             READ TABLE it_MKPF_MSEG 
                       WITH KEY mat_kdauf = w_vbap-vbeln mat_kdpos = w_vbap-posnr
                        BINARY SEARCH. 
             IF sy-subrc &amp;lt;&amp;gt; 0.  
               APPEND w_vbap TO t_vbap_remain.
            ENDIF. 
         ENDIF. 
 ENDLOOP. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2010 09:55:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-query/m-p/6549807#M1429362</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-29T09:55:59Z</dc:date>
    </item>
  </channel>
</rss>

