<?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 with BSEG in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685635#M887501</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These are the queries i am using in my report to fetch the line item data from bseg.functional guys are very adamant and dont want to use any other tables than BSEG.Kindly suggest me what can be done to improve the performance as this report takes a lot of time to run.&lt;/P&gt;&lt;P&gt;Suggest me how can i optimize the queries involved for improved performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BELNR BUKRS FROM BSEG INTO TABLE L_DOC_NO&lt;/P&gt;&lt;P&gt;                               WHERE BUKRS IN S_BUKRS&lt;/P&gt;&lt;P&gt;                               AND   GJAHR = P_GJAHR&lt;/P&gt;&lt;P&gt;                               AND   HKONT IN S_SAKNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR L_DOC_NO.&lt;/P&gt;&lt;P&gt;  SORT L_DOC_NO BY BELNR.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Selecting the Document Number Based on the selection-screen.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT BELNR BUKRS BUDAT CPUDT  BLART MONAT FROM BKPF INTO TABLE L_BKPF&lt;/P&gt;&lt;P&gt;  FOR ALL ENTRIES IN L_DOC_NO&lt;/P&gt;&lt;P&gt;                        WHERE BUKRS = L_DOC_NO-BUKRS AND&lt;/P&gt;&lt;P&gt;                              BELNR = L_DOC_NO-BELNR AND&lt;/P&gt;&lt;P&gt;                              GJAHR = P_GJAHR AND&lt;/P&gt;&lt;P&gt;                              BUDAT IN S_BUDAT AND&lt;/P&gt;&lt;P&gt;                              MONAT IN S_MONAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Fetch the Line Items&lt;/P&gt;&lt;P&gt;  SORT L_BKPF BY BELNR.&lt;/P&gt;&lt;P&gt;  SELECT BELNR BUKRS BUZEI HKONT  SHKZG WRBTR FROM BSEG INTO TABLE L_BSEG&lt;/P&gt;&lt;P&gt;                                FOR ALL ENTRIES IN L_BKPF&lt;/P&gt;&lt;P&gt;                             WHERE BUKRS = L_BKPF-BUKRS&lt;/P&gt;&lt;P&gt;                             AND   BELNR = L_BKPF-BELNR&lt;/P&gt;&lt;P&gt;                             AND   GJAHR = P_GJAHR&lt;/P&gt;&lt;P&gt;                             AND   BUZEI BETWEEN '001' AND '999'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Apr 2008 06:55:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-11T06:55:06Z</dc:date>
    <item>
      <title>Performance Issue with BSEG</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685635#M887501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These are the queries i am using in my report to fetch the line item data from bseg.functional guys are very adamant and dont want to use any other tables than BSEG.Kindly suggest me what can be done to improve the performance as this report takes a lot of time to run.&lt;/P&gt;&lt;P&gt;Suggest me how can i optimize the queries involved for improved performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BELNR BUKRS FROM BSEG INTO TABLE L_DOC_NO&lt;/P&gt;&lt;P&gt;                               WHERE BUKRS IN S_BUKRS&lt;/P&gt;&lt;P&gt;                               AND   GJAHR = P_GJAHR&lt;/P&gt;&lt;P&gt;                               AND   HKONT IN S_SAKNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR L_DOC_NO.&lt;/P&gt;&lt;P&gt;  SORT L_DOC_NO BY BELNR.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Selecting the Document Number Based on the selection-screen.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT BELNR BUKRS BUDAT CPUDT  BLART MONAT FROM BKPF INTO TABLE L_BKPF&lt;/P&gt;&lt;P&gt;  FOR ALL ENTRIES IN L_DOC_NO&lt;/P&gt;&lt;P&gt;                        WHERE BUKRS = L_DOC_NO-BUKRS AND&lt;/P&gt;&lt;P&gt;                              BELNR = L_DOC_NO-BELNR AND&lt;/P&gt;&lt;P&gt;                              GJAHR = P_GJAHR AND&lt;/P&gt;&lt;P&gt;                              BUDAT IN S_BUDAT AND&lt;/P&gt;&lt;P&gt;                              MONAT IN S_MONAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Fetch the Line Items&lt;/P&gt;&lt;P&gt;  SORT L_BKPF BY BELNR.&lt;/P&gt;&lt;P&gt;  SELECT BELNR BUKRS BUZEI HKONT  SHKZG WRBTR FROM BSEG INTO TABLE L_BSEG&lt;/P&gt;&lt;P&gt;                                FOR ALL ENTRIES IN L_BKPF&lt;/P&gt;&lt;P&gt;                             WHERE BUKRS = L_BKPF-BUKRS&lt;/P&gt;&lt;P&gt;                             AND   BELNR = L_BKPF-BELNR&lt;/P&gt;&lt;P&gt;                             AND   GJAHR = P_GJAHR&lt;/P&gt;&lt;P&gt;                             AND   BUZEI BETWEEN '001' AND '999'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 06:55:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685635#M887501</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T06:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Issue with BSEG</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685636#M887502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;since BSEG is a cluster table.. any querry on that table will hamper the perfirmance...&lt;/P&gt;&lt;P&gt;use more conditions in where clause to reduce the search area..&lt;/P&gt;&lt;P&gt;otherwise ask for other tables from where to fetch the data....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 07:11:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685636#M887502</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T07:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Issue with BSEG</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685637#M887503</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;Try this....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: s_cursor TYPE cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN CURSOR WITH HOLD s_cursor FOR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BELNR BUKRS FROM BSEG&lt;/P&gt;&lt;P&gt;WHERE BUKRS IN S_BUKRS&lt;/P&gt;&lt;P&gt;AND GJAHR = P_GJAHR&lt;/P&gt;&lt;P&gt;AND HKONT IN S_SAKNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;  FETCH NEXT CURSOR s_cursor&lt;/P&gt;&lt;P&gt;             APPENDING&lt;/P&gt;&lt;P&gt;             TABLE L_DOC_NO&lt;/P&gt;&lt;P&gt;             PACKAGE SIZE '2000'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    CLOSE CURSOR s_cursor.&lt;/P&gt;&lt;P&gt;    EXIT.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDDO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF L_DOC_NO[] is initial.&lt;/P&gt;&lt;P&gt;MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR L_DOC_NO.&lt;/P&gt;&lt;P&gt;SORT L_DOC_NO BY BELNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Selecting the Document Number Based on the selection-screen.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN CURSOR WITH HOLD s_cursor FOR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BELNR BUKRS BUDAT CPUDT BLART MONAT FROM BKPF &lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN L_DOC_NO&lt;/P&gt;&lt;P&gt;WHERE BUKRS = L_DOC_NO-BUKRS AND&lt;/P&gt;&lt;P&gt;BELNR = L_DOC_NO-BELNR AND&lt;/P&gt;&lt;P&gt;GJAHR = P_GJAHR AND&lt;/P&gt;&lt;P&gt;BUDAT IN S_BUDAT AND&lt;/P&gt;&lt;P&gt;MONAT IN S_MONAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;  FETCH NEXT CURSOR s_cursor&lt;/P&gt;&lt;P&gt;             APPENDING&lt;/P&gt;&lt;P&gt;             TABLE L_BKPF&lt;/P&gt;&lt;P&gt;             PACKAGE SIZE '2000'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    CLOSE CURSOR s_cursor.&lt;/P&gt;&lt;P&gt;    EXIT.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDDO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF L_BKPF[] is initial.&lt;/P&gt;&lt;P&gt;MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Fetch the Line Items&lt;/P&gt;&lt;P&gt;SORT L_BKPF BY BELNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN CURSOR WITH HOLD s_cursor FOR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BELNR BUKRS BUZEI HKONT SHKZG WRBTR FROM BSEG&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN L_BKPF&lt;/P&gt;&lt;P&gt;WHERE BUKRS = L_BKPF-BUKRS&lt;/P&gt;&lt;P&gt;AND BELNR = L_BKPF-BELNR&lt;/P&gt;&lt;P&gt;AND GJAHR = P_GJAHR&lt;/P&gt;&lt;P&gt;AND BUZEI BETWEEN '001' AND '999'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;  FETCH NEXT CURSOR s_cursor&lt;/P&gt;&lt;P&gt;             APPENDING&lt;/P&gt;&lt;P&gt;             TABLE L_BSEG&lt;/P&gt;&lt;P&gt;             PACKAGE SIZE '2000'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    CLOSE CURSOR s_cursor.&lt;/P&gt;&lt;P&gt;    EXIT.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDDO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF L_BSEG[] is initial.&lt;/P&gt;&lt;P&gt;MESSAGE ID 'ZTFI' TYPE 'E' NUMBER 006.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 13:32:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685637#M887503</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T13:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Issue with BSEG</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685638#M887504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mohammad,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why are you selecting records from table BSEG twice? Table BKPF and BSEG are usually very large tables. The more the selects the worse the performance. Look at the code below. It does the same thing you are trying to do and will work faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_bkpf,
         bukrs TYPE bkpf-bukrs,
         belnr TYPE bkpf-belnr,
         budat TYPE bkpf-budat,
         cpudt TYPE bkpf-cpudt,
         blart TYPE bkpf-blart,
         monat TYPE bkpf-monat,
       END OF ty_bkpf,

       BEGIN OF ty_bseg,
         belnr TYPE bseg-belnr,
         bukrs TYPE bseg-bukrs,
         buzei TYPE bseg-buzei,
         hkont TYPE bseg-hkont,
         shkzg TYPE bseg-shkzg,
         wrbtr TYPE bseg-wrbtr,
       END OF ty_bseg.

DATA: t_bkpf TYPE TABLE OF ty_bkpf,
      t_bseg TYPE TABLE OF ty_bseg.

SELECT bukrs
       belnr
       budat
       cpudt
       blart
       monat
  FROM bkpf
  INTO TABLE t_bkpf
  WHERE bukrs IN s_bukrs
  AND   gjahr EQ p_gjahr
  AND   budat IN s_budat
  AND   monat IN s_monat.

IF sy-subrc EQ 0.

  SELECT belnr
         bukrs
         buzei
         hkont
         shkzg
         wrbtr
    FROM bseg
    INTO TABLE t_bseg
    FOR ALL ENTRIES IN t_bkpf
    WHERE bukrs EQ t_bkpf-bukrs
    AND   belnr EQ t_bkpf-belnr
    AND   gjahr EQ t_bkpf-gjahr
    AND   hkont IN s_saknr.

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 14:16:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685638#M887504</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-11T14:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Performance Issue with BSEG</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685639#M887505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your main selection is by BUKRS and HKONT. This demands using the index tables BSIS and BSAS to quickly find line items for a selection of G/L accounts, &lt;EM&gt;provided "line item display" is switched on for all G/L accounts&lt;/EM&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your access would be BSIS and BSAS then select "for all entries" on BKPF. And BKPF is only needed for CPUDT, since all other fields you are selecting are available from BSIS and BSAS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 14:27:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-with-bseg/m-p/3685639#M887505</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-04-11T14:27:20Z</dc:date>
    </item>
  </channel>
</rss>

