<?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 Regarding Performance pbl in SQL query. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-performance-pbl-in-sql-query/m-p/917390#M58420</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey guys,&lt;/P&gt;&lt;P&gt;Could somebody help me over this posting.&lt;/P&gt;&lt;P&gt;I have created TAX report. which retrieved records from BSIS and BSAS table to calculate consumption tax.&lt;/P&gt;&lt;P&gt;From SE30 and SQL trace i found that loop at BSIS and BSAS takes round trip&lt;/P&gt;&lt;P&gt;for each Input Period value.&lt;/P&gt;&lt;P&gt;could you please give me best coding alternate to my below coding part.&lt;/P&gt;&lt;P&gt;*&lt;DEL&gt;Main code&lt;/DEL&gt;--&lt;/P&gt;&lt;HR originaltext="---------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab_t001.(itab_t001-bukrs is company code list,for each company code)&lt;/P&gt;&lt;P&gt;WK_MONAT = '01'.&lt;/P&gt;&lt;P&gt;  DO.&lt;/P&gt;&lt;P&gt;    IF WK_MONAT = P_MONAT. "p_monat is parameter input for period&lt;/P&gt;&lt;P&gt;      FLG_CUR_PERIOD = CNS_TRUE.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    PERFORM FRM_READ_DATA.         " RETRIEVE DATA FROM BSIS AND BSAS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    WK_MONAT = WK_MONAT + 1.&lt;/P&gt;&lt;P&gt;    IF WK_MONAT &amp;gt; P_MONAT.&lt;/P&gt;&lt;P&gt;      EXIT.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDDO.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;END of Main code----&lt;/P&gt;&lt;HR originaltext="------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Read FI documents from table BSIS/BSAS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM  FRM_READ_DATA.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data from table BSIS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT BELNR BUZEI BLART MWSKZ HKONT SHKZG DMBTR&lt;/P&gt;&lt;P&gt;    INTO CORRESPONDING FIELDS OF TABLE ITAB_BSIS&lt;/P&gt;&lt;P&gt;    FROM BSIS WHERE BUKRS = itab_t001-BUKRS AND  GJAHR = P_GJAHR AND  MONAT = WK_MONAT AND&lt;/P&gt;&lt;P&gt;    ( MWSKZ &amp;lt;&amp;gt; ' ' AND MWSKZ &amp;lt;&amp;gt; '**' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data from table BSAS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT BELNR BUZEI BLART MWSKZ HKONT SHKZG DMBTR&lt;/P&gt;&lt;P&gt;    APPENDING CORRESPONDING FIELDS OF TABLE ITAB_BSIS&lt;/P&gt;&lt;P&gt;    FROM BSAS  WHERE BUKRS = itab_t001-BUKRS AND  GJAHR = P_GJAHR AND MONAT = WK_MONAT AND&lt;/P&gt;&lt;P&gt;         ( MWSKZ &amp;lt;&amp;gt; ' ' AND MWSKZ &amp;lt;&amp;gt; '**' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data from table BSIS that includes non-consumption tax accounts&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT BELNR&lt;/P&gt;&lt;P&gt;   INTO TABLE ITAB_NO_TAX_DOC&lt;/P&gt;&lt;P&gt;    FROM BSIS WHERE BUKRS = itab_t001-BUKRS AND GJAHR = P_GJAHR AND&lt;/P&gt;&lt;P&gt;         MONAT = WK_MONAT AND HKONT IN S_NT_ACC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data from table BSAS that includes non-consumption tax accounts&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT BELNR  APPENDING TABLE ITAB_NO_TAX_DOC&lt;/P&gt;&lt;P&gt;    FROM BSAS WHERE BUKRS = itab_t001-BUKRS AND  GJAHR = P_GJAHR AND&lt;/P&gt;&lt;P&gt;         MONAT = WK_MONAT AND HKONT IN S_NT_ACC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...Proceeded with ABOVE fetched internal tables.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------" /&gt;&lt;P&gt;Note:&lt;/P&gt;&lt;P&gt; I found that BSIS and BSAS table have 10000s of records it takes 3hrs time to run this report(if i give 12months period). (for each month(ie 01month report takes 15minutes to execute.)&lt;/P&gt;&lt;P&gt;so i think instead calling BSiS twice, calling BSIS ones is wise.&lt;/P&gt;&lt;P&gt;could you pls help me how can i modify the code and should i have&lt;/P&gt;&lt;P&gt; to created any index here(if so mention how and which field)&lt;/P&gt;&lt;P&gt;pls feel free to ask if any addition code is required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you pls confirm.&lt;/P&gt;&lt;P&gt;ambichan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: ambi chan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Mar 2005 01:21:03 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-03-25T01:21:03Z</dc:date>
    <item>
      <title>Regarding Performance pbl in SQL query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-performance-pbl-in-sql-query/m-p/917390#M58420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey guys,&lt;/P&gt;&lt;P&gt;Could somebody help me over this posting.&lt;/P&gt;&lt;P&gt;I have created TAX report. which retrieved records from BSIS and BSAS table to calculate consumption tax.&lt;/P&gt;&lt;P&gt;From SE30 and SQL trace i found that loop at BSIS and BSAS takes round trip&lt;/P&gt;&lt;P&gt;for each Input Period value.&lt;/P&gt;&lt;P&gt;could you please give me best coding alternate to my below coding part.&lt;/P&gt;&lt;P&gt;*&lt;DEL&gt;Main code&lt;/DEL&gt;--&lt;/P&gt;&lt;HR originaltext="---------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab_t001.(itab_t001-bukrs is company code list,for each company code)&lt;/P&gt;&lt;P&gt;WK_MONAT = '01'.&lt;/P&gt;&lt;P&gt;  DO.&lt;/P&gt;&lt;P&gt;    IF WK_MONAT = P_MONAT. "p_monat is parameter input for period&lt;/P&gt;&lt;P&gt;      FLG_CUR_PERIOD = CNS_TRUE.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    PERFORM FRM_READ_DATA.         " RETRIEVE DATA FROM BSIS AND BSAS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    WK_MONAT = WK_MONAT + 1.&lt;/P&gt;&lt;P&gt;    IF WK_MONAT &amp;gt; P_MONAT.&lt;/P&gt;&lt;P&gt;      EXIT.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDDO.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;END of Main code----&lt;/P&gt;&lt;HR originaltext="------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Read FI documents from table BSIS/BSAS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM  FRM_READ_DATA.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data from table BSIS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT BELNR BUZEI BLART MWSKZ HKONT SHKZG DMBTR&lt;/P&gt;&lt;P&gt;    INTO CORRESPONDING FIELDS OF TABLE ITAB_BSIS&lt;/P&gt;&lt;P&gt;    FROM BSIS WHERE BUKRS = itab_t001-BUKRS AND  GJAHR = P_GJAHR AND  MONAT = WK_MONAT AND&lt;/P&gt;&lt;P&gt;    ( MWSKZ &amp;lt;&amp;gt; ' ' AND MWSKZ &amp;lt;&amp;gt; '**' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data from table BSAS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT BELNR BUZEI BLART MWSKZ HKONT SHKZG DMBTR&lt;/P&gt;&lt;P&gt;    APPENDING CORRESPONDING FIELDS OF TABLE ITAB_BSIS&lt;/P&gt;&lt;P&gt;    FROM BSAS  WHERE BUKRS = itab_t001-BUKRS AND  GJAHR = P_GJAHR AND MONAT = WK_MONAT AND&lt;/P&gt;&lt;P&gt;         ( MWSKZ &amp;lt;&amp;gt; ' ' AND MWSKZ &amp;lt;&amp;gt; '**' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data from table BSIS that includes non-consumption tax accounts&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT BELNR&lt;/P&gt;&lt;P&gt;   INTO TABLE ITAB_NO_TAX_DOC&lt;/P&gt;&lt;P&gt;    FROM BSIS WHERE BUKRS = itab_t001-BUKRS AND GJAHR = P_GJAHR AND&lt;/P&gt;&lt;P&gt;         MONAT = WK_MONAT AND HKONT IN S_NT_ACC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data from table BSAS that includes non-consumption tax accounts&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT BELNR  APPENDING TABLE ITAB_NO_TAX_DOC&lt;/P&gt;&lt;P&gt;    FROM BSAS WHERE BUKRS = itab_t001-BUKRS AND  GJAHR = P_GJAHR AND&lt;/P&gt;&lt;P&gt;         MONAT = WK_MONAT AND HKONT IN S_NT_ACC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...Proceeded with ABOVE fetched internal tables.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------" /&gt;&lt;P&gt;Note:&lt;/P&gt;&lt;P&gt; I found that BSIS and BSAS table have 10000s of records it takes 3hrs time to run this report(if i give 12months period). (for each month(ie 01month report takes 15minutes to execute.)&lt;/P&gt;&lt;P&gt;so i think instead calling BSiS twice, calling BSIS ones is wise.&lt;/P&gt;&lt;P&gt;could you pls help me how can i modify the code and should i have&lt;/P&gt;&lt;P&gt; to created any index here(if so mention how and which field)&lt;/P&gt;&lt;P&gt;pls feel free to ask if any addition code is required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you pls confirm.&lt;/P&gt;&lt;P&gt;ambichan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: ambi chan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2005 01:21:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-performance-pbl-in-sql-query/m-p/917390#M58420</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-25T01:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Performance pbl in SQL query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-performance-pbl-in-sql-query/m-p/917391#M58421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can somebody take over this message!could be more apprecialble.&lt;/P&gt;&lt;P&gt;ambichan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2005 07:36:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-performance-pbl-in-sql-query/m-p/917391#M58421</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-25T07:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Performance pbl in SQL query.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-performance-pbl-in-sql-query/m-p/917392#M58422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ambichan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Few things that can be done to the below code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Dont put select queries inside the "loop at itab_t001....endloop" statement. &lt;/P&gt;&lt;P&gt;Instead use &amp;lt;b&amp;gt;FOR ALL ENTRIES&amp;lt;/b&amp;gt; IN itab_t001 for the queries. Then you can use READ stmt to get the values.&lt;/P&gt;&lt;P&gt;NOTE: Make sure that you select all &amp;lt;b&amp;gt;key fields&amp;lt;/b&amp;gt; from the databse when using FOR all Entries. &lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;This will avoid hitting of the DB table multiple time.&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Avoid "INTO CORRESPONDING FIELDS OF TABLE" in select queries. Modify the internal table to suit the strucutre of the databse table.&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;This will make the query faster&amp;lt;/i&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Make sure that the fields in the select query are in the same order as that in DB table.&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;This will also make the query faster&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try these changes and performance should increase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Saji.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Mar 2005 07:46:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-performance-pbl-in-sql-query/m-p/917392#M58422</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-03-25T07:46:54Z</dc:date>
    </item>
  </channel>
</rss>

