<?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 Query problem. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-problem/m-p/3930830#M941200</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Question1): How to optimize this query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT ZBRNM PRODH  SUM( ZBIL1 ) SUM( ZSTD1 )   INTO TABLE IT_BRAND&lt;/P&gt;&lt;P&gt;  FROM CF951&lt;/P&gt;&lt;P&gt;  WHERE&lt;/P&gt;&lt;P&gt;YEARB = LV_PREYEAR AND PERDE = LV_PERDE AND VERSIO = '001' AND PLACTI&lt;/P&gt;&lt;P&gt;='0'&lt;/P&gt;&lt;P&gt;GROUP BY ZBRNM PRODH&lt;/P&gt;&lt;P&gt;  ORDER BY ZBRNM.&lt;/P&gt;&lt;P&gt;  LOOP AT IT_BRAND.&lt;/P&gt;&lt;P&gt;    LV_PREMARGIN = ( IT_BRAND-SUMBIL1 ) - ( IT_BRAND-SUMSTD1 ).&lt;/P&gt;&lt;P&gt; LV_PREPERMARGIN = ( LV_PREMARGIN / IT_CURRBRAND-SUMBIL1 ) * 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    WRITE: / IT_BRAND-ZBRNM, IT_BRAND-PRODH, IT_BRAND-SUMBIL1,&lt;/P&gt;&lt;P&gt; IT_BRAND-SUMSTD1,&lt;/P&gt;&lt;P&gt;    LV_PREMARGIN.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question 2)  In given query perde is fiscal period and i want to run this query from different fiscal period ( i means to say for 11 times for a year). how to give the range in where clasue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If my question is not clear let me know i will give more details.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 May 2008 19:20:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-28T19:20:02Z</dc:date>
    <item>
      <title>Query problem.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-problem/m-p/3930830#M941200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Question1): How to optimize this query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT ZBRNM PRODH  SUM( ZBIL1 ) SUM( ZSTD1 )   INTO TABLE IT_BRAND&lt;/P&gt;&lt;P&gt;  FROM CF951&lt;/P&gt;&lt;P&gt;  WHERE&lt;/P&gt;&lt;P&gt;YEARB = LV_PREYEAR AND PERDE = LV_PERDE AND VERSIO = '001' AND PLACTI&lt;/P&gt;&lt;P&gt;='0'&lt;/P&gt;&lt;P&gt;GROUP BY ZBRNM PRODH&lt;/P&gt;&lt;P&gt;  ORDER BY ZBRNM.&lt;/P&gt;&lt;P&gt;  LOOP AT IT_BRAND.&lt;/P&gt;&lt;P&gt;    LV_PREMARGIN = ( IT_BRAND-SUMBIL1 ) - ( IT_BRAND-SUMSTD1 ).&lt;/P&gt;&lt;P&gt; LV_PREPERMARGIN = ( LV_PREMARGIN / IT_CURRBRAND-SUMBIL1 ) * 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    WRITE: / IT_BRAND-ZBRNM, IT_BRAND-PRODH, IT_BRAND-SUMBIL1,&lt;/P&gt;&lt;P&gt; IT_BRAND-SUMSTD1,&lt;/P&gt;&lt;P&gt;    LV_PREMARGIN.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question 2)  In given query perde is fiscal period and i want to run this query from different fiscal period ( i means to say for 11 times for a year). how to give the range in where clasue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If my question is not clear let me know i will give more details.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 May 2008 19:20:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-problem/m-p/3930830#M941200</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-28T19:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Query problem.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-problem/m-p/3930831#M941201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1) where exactly do you want to improve performance? the Select statement? the loop? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sometimes, doing too much in your select statement will really clog your performance. i'd try taking out the SUMs and GROUPINGs...  do that separately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can always create a test program with your original Select statement &amp;amp; compare the execution time of it (and only it).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your loop can be optimized by looping at your itab into a work area, or even using field symbols, instead of using an itab with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) you want to run for all 12 fiscal periods at once? or one at a time? depending on how your variable lv_perde is declared... i would make it part of the screen selection with a select-options statement:&lt;/P&gt;&lt;P&gt;select-options: lv_perde for cf951-perde.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in your select statement you use:&lt;/P&gt;&lt;P&gt;WHERE perde  IN lv_perde&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 May 2008 21:15:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-problem/m-p/3930831#M941201</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-28T21:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Query problem.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-problem/m-p/3930832#M941202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Instead of order by use&lt;/P&gt;&lt;P&gt;SELECT ZBRNM PRODH SUM( ZBIL1 ) SUM( ZSTD1 ) INTO TABLE IT_BRAND&lt;/P&gt;&lt;P&gt;FROM CF951&lt;/P&gt;&lt;P&gt;WHERE&lt;/P&gt;&lt;P&gt;YEARB = LV_PREYEAR AND PERDE = LV_PERDE AND VERSIO = '001' AND PLACTI&lt;/P&gt;&lt;P&gt;='0'&lt;/P&gt;&lt;P&gt;GROUP BY ZBRNM PRODH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort  IT_BRAND by ZBRNM ascending.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;declare a rnages variable...pass all the values into it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and in where clause use YEARB in r_YEAR&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2008 03:36:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-problem/m-p/3930832#M941202</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2008-05-29T03:36:01Z</dc:date>
    </item>
  </channel>
</rss>

