<?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: Peformance on select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981625#M401398</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Chnadra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bettre chnage the code like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add a field in the itab i_zrat_tmp1 for V_PREV_year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at i_zrat_tmp1 into wa_zrat_tmp1.
clear: v_prev_year.
i_zrat_tmp1-v_prev_year = wa_zrat_tmp1-startdate - 365 + 3.
modify i_zrat_tmp1.
endloop.


SELECT startdate enddate
vkorg kunag kunwe oicontnr werks matnr oic_mot actvolume
FROM ZRATABILITY APPENDING table i_zrat_prev
FOR all entries in i_zrat_tmp
WHERE ( startdate &amp;lt;= v_prev_year
AND enddate &amp;gt;= v_prev_year )
AND vkorg EQ i_zrat_tmp-vkorg
AND kunag EQ i_zrat_tmp-kunag
AND kunwe EQ i_zrat_tmp-kunwe
AND oicontnr EQ i_zrat_tmp-oicontnr
AND werks EQ i_zrat_tmp-werks
AND matnr EQ i_zrat_tmp-matnr
AND oic_mot EQ i_zrat_tmp-oic_mot.

Hope this will definetly improve the performance.

if useful reward

Vasanth


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Mar 2007 22:38:23 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-03-02T22:38:23Z</dc:date>
    <item>
      <title>Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981622#M401395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have written a code as below. The select statement is using all the key fields. But the performance is very bad. Can anybody suggest best alternated to this code. Where performance will be good. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chandra Kumar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_zrat_tmp1 into wa_zrat_tmp1.&lt;/P&gt;&lt;P&gt;      clear: v_prev_year.&lt;/P&gt;&lt;P&gt;      v_prev_year = wa_zrat_tmp1-startdate - 365 + 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      SELECT startdate enddate&lt;/P&gt;&lt;P&gt;      vkorg kunag kunwe oicontnr werks matnr oic_mot actvolume&lt;/P&gt;&lt;P&gt;      FROM ZRATABILITY APPENDING table i_zrat_prev&lt;/P&gt;&lt;P&gt;          FOR all entries in i_zrat_tmp&lt;/P&gt;&lt;P&gt;          WHERE ( startdate &amp;lt;= v_prev_year&lt;/P&gt;&lt;P&gt;            AND     enddate &amp;gt;= v_prev_year )&lt;/P&gt;&lt;P&gt;            AND   vkorg    EQ i_zrat_tmp-vkorg&lt;/P&gt;&lt;P&gt;            AND   kunag    EQ i_zrat_tmp-kunag&lt;/P&gt;&lt;P&gt;            AND   kunwe    EQ i_zrat_tmp-kunwe&lt;/P&gt;&lt;P&gt;            AND   oicontnr EQ i_zrat_tmp-oicontnr&lt;/P&gt;&lt;P&gt;            AND   werks    EQ i_zrat_tmp-werks&lt;/P&gt;&lt;P&gt;            AND   matnr    EQ i_zrat_tmp-matnr&lt;/P&gt;&lt;P&gt;            AND   oic_mot  EQ i_zrat_tmp-oic_mot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 22:22:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981622#M401395</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T22:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981623#M401396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is this going to fetch only one record each time ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hmm...check if your fields you are selecting are in the same order of the database table, also the fields in the where clause. That improves some times.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 22:27:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981623#M401396</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T22:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981624#M401397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have already used for all entries. Other then all entries on a table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also have another table from which i need to calculate the date and use in the select statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 22:34:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981624#M401397</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T22:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981625#M401398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Chnadra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bettre chnage the code like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add a field in the itab i_zrat_tmp1 for V_PREV_year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at i_zrat_tmp1 into wa_zrat_tmp1.
clear: v_prev_year.
i_zrat_tmp1-v_prev_year = wa_zrat_tmp1-startdate - 365 + 3.
modify i_zrat_tmp1.
endloop.


SELECT startdate enddate
vkorg kunag kunwe oicontnr werks matnr oic_mot actvolume
FROM ZRATABILITY APPENDING table i_zrat_prev
FOR all entries in i_zrat_tmp
WHERE ( startdate &amp;lt;= v_prev_year
AND enddate &amp;gt;= v_prev_year )
AND vkorg EQ i_zrat_tmp-vkorg
AND kunag EQ i_zrat_tmp-kunag
AND kunwe EQ i_zrat_tmp-kunwe
AND oicontnr EQ i_zrat_tmp-oicontnr
AND werks EQ i_zrat_tmp-werks
AND matnr EQ i_zrat_tmp-matnr
AND oic_mot EQ i_zrat_tmp-oic_mot.

Hope this will definetly improve the performance.

if useful reward

Vasanth


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 22:38:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981625#M401398</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T22:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981626#M401399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey, i read it thouroughly and corrected my statement. &lt;/P&gt;&lt;P&gt;In the loop of i_z1 you are writing the selecting but you are not using any other fields except the date and you are doing the for all entries. Rather i suggest you take the date field also in the first internal table for which you are doing the for all entries. That way you can eliminate the loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 22:38:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981626#M401399</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T22:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981627#M401400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey vasantha,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;chandra is looping at a different table calculating the date &amp;amp; doing for all entries of another table and using this date. so, what  you say is not possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 22:40:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981627#M401400</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T22:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981628#M401401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For each entry of table i_zrat_tmp it will fetch one record. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the select statement the fields are in the same order in the database and i have used all the key fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 22:58:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981628#M401401</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T22:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981629#M401402</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;Make this change&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at i_zrat_tmp1 into wa_zrat_tmp1.
clear: v_prev_year.
v_prev_year = wa_zrat_tmp1-startdate - 365 + 3.

SELECT startdate enddate
vkorg kunag kunwe oicontnr werks matnr oic_mot actvolume
FROM ZRATABILITY APPENDING table i_zrat_prev
*FOR all entries in i_zrat_tmp  " Remove for all entries.
WHERE ( startdate LE v_prev_year  " -----
AND enddate GE v_prev_year )      " -----  
AND vkorg EQ i_zrat_tmp-vkorg
AND kunag EQ i_zrat_tmp-kunag
AND kunwe EQ i_zrat_tmp-kunwe
AND oicontnr EQ i_zrat_tmp-oicontnr
AND werks EQ i_zrat_tmp-werks
AND matnr EQ i_zrat_tmp-matnr
AND oic_mot EQ i_zrat_tmp-oic_mot.

endloop. 
IF this is also not serving then remove appending and use SELECT --- ENDSELECT
Regards,
Vasanth
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Vasanth M&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 23:06:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981629#M401402</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T23:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981630#M401403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The key performance issue here is a SELECT is defined in a LOOP. Try to put your query outside the loop based upon your logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why cant you have this field 'v_prev_year'  in the table 'i_zrat_tmp'?&lt;/P&gt;&lt;P&gt;Create one field and modify the field with 'v_prev_year = wa_zrat_tmp-startdate - 365 + 3.'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then, you do for all entries on i_zrat_tmp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 23:17:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981630#M401403</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T23:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981631#M401404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try USING the following query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF i_zrat_tmp[] IS NOT INITIAL. (Always use this while using FOR ALL ENTRIES)&lt;/P&gt;&lt;P&gt;SELECT startdate enddate&lt;/P&gt;&lt;P&gt;vkorg kunag kunwe oicontnr werks matnr oic_mot actvolume&lt;/P&gt;&lt;P&gt;FROM ZRATABILITY APPENDING table i_zrat_prev&lt;/P&gt;&lt;P&gt;FOR all entries in i_zrat_tmp&lt;/P&gt;&lt;P&gt;WHERE vkorg EQ i_zrat_tmp-vkorg&lt;/P&gt;&lt;P&gt;AND kunag EQ i_zrat_tmp-kunag&lt;/P&gt;&lt;P&gt;AND kunwe EQ i_zrat_tmp-kunwe&lt;/P&gt;&lt;P&gt;AND oicontnr EQ i_zrat_tmp-oicontnr&lt;/P&gt;&lt;P&gt;AND werks EQ i_zrat_tmp-werks&lt;/P&gt;&lt;P&gt;AND matnr EQ i_zrat_tmp-matnr&lt;/P&gt;&lt;P&gt;AND oic_mot EQ i_zrat_tmp-oic_mot.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_zrat_tmp1 into wa_zrat_tmp1.&lt;/P&gt;&lt;P&gt;clear: v_prev_year.&lt;/P&gt;&lt;P&gt;v_prev_year = wa_zrat_tmp1-startdate - 365 + 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_zrat_prev into wa_zrat_prev where startdate &amp;lt;= v_prev_year&lt;/P&gt;&lt;P&gt;AND enddate &amp;gt;= v_prev_year&lt;/P&gt;&lt;P&gt;wa_new_itab = wa_zrat_prev.&lt;/P&gt;&lt;P&gt;append wa_new_itab to i_new_itab.&lt;/P&gt;&lt;P&gt;clear wa_new_itab.&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;hope this will help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please close the thread if Solved.&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Ashwani&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 23:27:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981631#M401404</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T23:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981632#M401405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;please CLOSE the thread if solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ashwani&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2007 00:23:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981632#M401405</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-03T00:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Peformance on select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981633#M401406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The question is answered thanks for all of you. Who replied&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Mar 2007 20:07:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/peformance-on-select-statement/m-p/1981633#M401406</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-06T20:07:47Z</dc:date>
    </item>
  </channel>
</rss>

