<?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: Bseg performance issue in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144767#M1976350</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;If you are specific to select data where koart eq 'K', &lt;/P&gt;&lt;P&gt;It is better to use BSIK and BSAK tables (which are already indexed).&lt;/P&gt;&lt;P&gt;This will be giving faster results.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Venkat&lt;/P&gt;</description>
    <pubDate>Sun, 10 May 2020 08:44:30 GMT</pubDate>
    <dc:creator>venkateswaran_k</dc:creator>
    <dc:date>2020-05-10T08:44:30Z</dc:date>
    <item>
      <title>Bseg performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144764#M1976347</link>
      <description>&lt;P&gt;I am having performance issue with the below select statement.&lt;/P&gt;
  &lt;P&gt;Select belnr dmbtr hkont koart zlsch from bseg into table it_bseg for all entries in it_bkpf where belnr =it_bkpf-belnr and koart eq 'K'.&lt;/P&gt;
  &lt;P&gt;Please suggest how can I improve the performance issue of this statement&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 07:35:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144764#M1976347</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-05-10T07:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Bseg performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144765#M1976348</link>
      <description>&lt;P&gt;Hi - what are you trying to achieve?&lt;/P&gt;&lt;P&gt;It may be faster to access the index tables such as BSIK or even the logical database (we use BRM for financial documents)&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 07:53:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144765#M1976348</guid>
      <dc:creator>TammyPowlas</dc:creator>
      <dc:date>2020-05-10T07:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Bseg performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144766#M1976349</link>
      <description>&lt;P&gt;&lt;STRONG&gt;You will have to read the db with partial primary key or use/create indexes for your key. &lt;/STRONG&gt;(Currently you dont.)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;Do an &lt;STRONG&gt;ST05 SQL trace analysis &lt;/STRONG&gt;before and after changes of your coding in dev, quality and prod, to see whether for the db access keys were used, or whether a sequential search (searching the entire db instead of by keys) was performed:&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://blogs.sap.com/2007/09/05/the-sql-trace-st05-quick-and-easy/"&gt;https://blogs.sap.com/2007/09/05/the-sql-trace-st05-quick-and-easy/&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://blogs.sap.com/2014/02/11/code-inspector-integration-into-sql-trace-of-st05/"&gt;https://blogs.sap.com/2014/02/11/code-inspector-integration-into-sql-trace-of-st05/&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Right now, your best option &lt;/STRONG&gt;is to add the &lt;STRONG&gt;Company Code&lt;/STRONG&gt; (BUKRS) into your select statement. &lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;If it is just one you need to consider, that is perfect&lt;BR /&gt;DATA yourbukr TYPE bukrs. " set single bukrs&lt;/LI&gt;&lt;LI&gt;If it is multiple, use a range object with Include Equals options &lt;BR /&gt;DATA yourbukrs TYPE RANGE OF bukrs. " set multiple bukrs, e.g. sign=I,option=EQ,low=yourbukr&lt;BR /&gt;(definitly no exclusions, if patterns or ranges, they need to make use of the key or partial key and restrict the values very good and ). &lt;/LI&gt;&lt;LI&gt;But even if you have to add all available Company Codes in the range object, it would still perform better than just having the Document Number (BELNR), as it will take use of a key search instead of a sequential search.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;You might have to consider changing the "FOR ALL ENTRIES IN it_bkpf" into a range statement.&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;e.g. "DATA yourbelnrs TYPE RANGE OF belnr_d" and fill with "sign=I,option=EQ,low=yourbelnr" from IT_BKPF. &lt;/LI&gt;&lt;LI&gt;But than you can run into a too many restrictions dump, depending on the amount of restrictions and the setting of your system for restrictions (e.g. &amp;gt; 10'000)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If you want to tweak it even more, you need to add the Fiscal Year (GJAHR). I assume adding the Number of Line Item (BUZEI) is not helpful, as there would be too many values to consider. Not useful, if you add restriction(s) that are going to add/include all possible BUZEI.&lt;/P&gt;&lt;P&gt;Here are the Key components of BSEG.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;BUKRS	BUKRS	CHAR	4	0	0	Company Code
BELNR	BELNR_D	CHAR	10	0	0	Accounting Document Number
GJAHR	GJAHR	NUMC	4	0	0	Fiscal Year
BUZEI	BUZEI	NUMC	3	0	0	Number of Line Item Within Accounting Document
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is how your coding would look like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;" necessary to tweak performance
DATA yourbukr TYPE bukrs. " set single bukrs
DATA yourbukrs TYPE RANGE OF bukrs. " set multiple bukrs, e.g. sign=I,option=EQ,low=yourbukr
" optional to tweak performance a little more
" Range IN yourbelnrs instead of FOR ALL ENTRIES IN it_bkpf
DATA yourbelnrs TYPE RANGE OF belnr_d. " set multiple belnr, e.g. sign=I,option=EQ,low=yourbelnr from IT_BKPF
" Selecting gjahr also
DATA yourgjahr TYPE gjahr. " set single gjahr
DATA yourgjahrs TYPE RANGE OF gjahr. " set multiple gjahr, e.g. sign=I,option=EQ,low=yourgjahr

" Option A) with FOR ALL ENTRIES IN it_bkpf
SELECT belnr dmbtr hkont koart zlsch 
FROM bseg INTO TABLE it_bseg 
FOR ALL ENTRIES IN it_bkpf 
WHERE BUKRS = yourbukr   " necessary for performance, if it's multiple, use range IN yourbukrs 
  AND belnr = it_bkpf-belnr 
* AND gjahr = yourgjahr  " optional, and if it's multipe, use range IN yourgjahrs
  AND koart eq 'K'.

" Option B) with range IN yourbelnrs instead of FOR ALL ENTRIES IN it_bkpf
SELECT belnr dmbtr hkont koart zlsch 
FROM bseg INTO TABLE it_bseg 
WHERE BUKRS = yourbukr    " necessary for performance, if it's multiple, use range IN yourbukrs 
  AND belnr IN yourbelnrs " not possible if there are too many restrictions (e.g. &amp;gt; 10'000)
* AND gjahr = yourgjahr   " optional, and if it's multipe, use range IN yourgjahrs
  AND koart eq 'K'.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 May 2020 08:05:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144766#M1976349</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-05-10T08:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Bseg performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144767#M1976350</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;If you are specific to select data where koart eq 'K', &lt;/P&gt;&lt;P&gt;It is better to use BSIK and BSAK tables (which are already indexed).&lt;/P&gt;&lt;P&gt;This will be giving faster results.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Venkat&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 08:44:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144767#M1976350</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2020-05-10T08:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Bseg performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144768#M1976351</link>
      <description>&lt;P&gt;You say "BSIK and BSAK tables (which are already indexed)."&lt;/P&gt;&lt;P&gt;I guess you mean implicitly that they already have an index with first indexed column BELNR.&lt;/P&gt;&lt;P&gt;(it's meaningless to only say that a table is indexed - i.e. say indexed by what columns)&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 16:13:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144768#M1976351</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-05-10T16:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Bseg performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144769#M1976352</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;sap_amit1111&lt;/SPAN&gt;, please let me know, if this is helping you, or whether there are still issues with your problem.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 09:58:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bseg-performance-issue/m-p/12144769#M1976352</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-05-20T09:58:40Z</dc:date>
    </item>
  </channel>
</rss>

