<?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: Nested SELECT FROM BSEG - performance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493011#M1063329</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, having a program that actually serves pure reporting purposes create a file on the app server is quite unusual. If your "open cursor" solution works, why not use that one. One more thought, have a look also at the "subquery" technique for select statements.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Sep 2008 08:32:43 GMT</pubDate>
    <dc:creator>ThomasZloch</dc:creator>
    <dc:date>2008-09-18T08:32:43Z</dc:date>
    <item>
      <title>Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493003#M1063321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I have a very simple program with 2 nested SELECTs, but with huge amount of data, and as the worst thing, on a cluster table BSEG with non-key access. I need to get the first set of data based on a certain criteria, and then the second set based on the first set. I can't use index tables such as BSID etc. Here is my program:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  SELECT bukrs belnr gjahr FROM bseg INTO ls_bseg1
     WHERE bukrs =  '0100' AND
           projk NE space AND
           ( koart = 'S' OR koart = 'A' ).
    SELECT bukrs belnr gjahr buzei rebzg rebzz dmbtr FROM bseg INTO ls_bseg2
           WHERE bukrs = ls_bseg1-bukrs AND
                 belnr = ls_bseg1-belnr AND
                 gjahr = ls_bseg1-gjahr AND
                 koart = 'K' AND
                 augdt &amp;gt; p_augdt.
      PERFORM write_line USING ls_bseg2.
    ENDSELECT.
  ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could anyone offer an advice on better performance? I will also try with internal tables, but I expect a short dump because of memory occupancy. I also have in mind using file on app server.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Igor&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 08:00:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493003#M1063321</guid>
      <dc:creator>former_member185943</dc:creator>
      <dc:date>2008-09-18T08:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493004#M1063322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Igor,&lt;/P&gt;&lt;P&gt; Instead of NESTED you write FOR ALL ENTRIES and check the performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sudharshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 08:02:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493004#M1063322</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-18T08:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493005#M1063323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Igor,&lt;/P&gt;&lt;P&gt; Check whether this query gives you the same result as expected in your nested statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT bukrs belnr gjahr buzei rebzg rebzz dmbtr &lt;/P&gt;&lt;P&gt;    FROM bseg INTO ls_bseg2&lt;/P&gt;&lt;P&gt;    WHERE bukrs = '0100' AND&lt;/P&gt;&lt;P&gt;                ( koart = 'S' OR koart = 'A' OR koart = 'K' ) AND&lt;/P&gt;&lt;P&gt;                 augdt &amp;gt; p_augdt AND&lt;/P&gt;&lt;P&gt;                 projk NE SPACE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sudharshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 08:12:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493005#M1063323</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-18T08:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493006#M1063324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sudharshan,&lt;/P&gt;&lt;P&gt;that's what I meant when I said that I'll try with internal tables. Thanks!&lt;/P&gt;&lt;P&gt;I just realized that I can't do nested SELECTs on the same table - I must use cursors. So the code is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  OPEN CURSOR l_curs_bseg1 FOR SELECT bukrs belnr gjahr FROM bseg
   WHERE bukrs =  '0100' AND
         projk NE space AND
         ( koart = 'S' OR koart = 'A' ).
  DO.
    FETCH NEXT CURSOR l_curs_bseg1 INTO ls_bseg1.
    IF sy-subrc NE 0.
      CLOSE CURSOR l_curs_bseg1.
      EXIT.
    ENDIF.
    OPEN CURSOR l_curs_bseg2 FOR SELECT bukrs belnr gjahr buzei rebzg rebzz dmbtr FROM bseg
           WHERE bukrs = ls_bseg1-bukrs AND
                 belnr = ls_bseg1-belnr AND
                 gjahr = ls_bseg1-gjahr AND
                 koart = 'K' AND
                 augdt &amp;gt; p_augdt.
    DO.
      FETCH NEXT CURSOR l_curs_bseg2  INTO ls_bseg2.
      IF sy-subrc NE 0.
        CLOSE CURSOR l_curs_bseg2.
        EXIT.
      ENDIF.
      PERFORM write_line USING ls_bseg2.
    ENDDO.
  ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but the question is the same.&lt;/P&gt;&lt;P&gt;Igor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. Why can't I edit my first post?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Igor Barbaric on Sep 18, 2008 10:19 AM &lt;/P&gt;&lt;P&gt;Sorry, one more correction in code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 08:14:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493006#M1063324</guid>
      <dc:creator>former_member185943</dc:creator>
      <dc:date>2008-09-18T08:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493007#M1063325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Based on your selection criteria for the outer select I don't see a way to speed it up. You obviously want all S- and A-type document items containing &lt;EM&gt;any&lt;/EM&gt; PSP element...even if you could create a secondary index for PROJK it would not help much.&lt;/P&gt;&lt;P&gt;So don't additionally waste memory space by using internal tables or for all entries, and let this bugger work in the background, probably gaining a top spot in the next early watch report.&lt;/P&gt;&lt;P&gt;If this is a really critical report, you might want to look into using some sort of exit at time of document posting, in order to fill an info structure with the relevant data, which can then be analysed quickly. Maybe there is even some FI standard functionality allowing for that.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 08:15:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493007#M1063325</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-09-18T08:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493008#M1063326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i think FOR ALL ENTRIES is the best way to increase the performance .....&lt;/P&gt;&lt;P&gt;use this and check performance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 08:18:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493008#M1063326</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-18T08:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493009#M1063327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; P.S. Why can't I edit my first post?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because there were already replies to it. Can't change history &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 08:20:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493009#M1063327</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-09-18T08:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493010#M1063328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Thomas!&lt;/P&gt;&lt;P&gt;What do you think about a text file on app server as storage for the first SELECT's result, and then doing second SELECT by reading the file? Doesn't sound promising, but just a thought...&lt;/P&gt;&lt;P&gt;Igor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Igor Barbaric on Sep 18, 2008 10:23 AM&lt;/P&gt;&lt;P&gt;Can't change history? Fair enough! &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 08:22:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493010#M1063328</guid>
      <dc:creator>former_member185943</dc:creator>
      <dc:date>2008-09-18T08:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493011#M1063329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, having a program that actually serves pure reporting purposes create a file on the app server is quite unusual. If your "open cursor" solution works, why not use that one. One more thought, have a look also at the "subquery" technique for select statements.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 08:32:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493011#M1063329</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-09-18T08:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493012#M1063330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;have a look at this (the key here is field PROJK and accessing table BSEG by key fields):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.- &lt;A href="http://sap.ittoolbox.com/groups/technical-functional/sap-dev/alternative-for-table-bseg-and-bsim-1530213" target="test_blank"&gt;http://sap.ittoolbox.com/groups/technical-functional/sap-dev/alternative-for-table-bseg-and-bsim-1530213&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2.- &lt;A href="http://www.sapnet.ru/viewtopic.php?t=458" target="test_blank"&gt;http://www.sapnet.ru/viewtopic.php?t=458&lt;/A&gt;&lt;/P&gt;&lt;P&gt;3.- &lt;A href="http://www.thaisapclub.com/forums/showthread.php?t=766&amp;amp;page=2" target="test_blank"&gt;http://www.thaisapclub.com/forums/showthread.php?t=766&amp;amp;page=2&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it´s just another option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Pablo Casamayor on Sep 18, 2008 10:32 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 20:08:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493012#M1063330</guid>
      <dc:creator>former_member182371</dc:creator>
      <dc:date>2008-09-18T20:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Nested SELECT FROM BSEG - performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493013#M1063331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Igor - what you really need is a secondary index table where the primary key is the project number and the table entries include the FI document number. I doubt if such a beast exists, but you might look for it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise, run it in the background. Not all problems have elegant solutions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On second though - you are using NE in the WHERE for PROJK, so even if you could find a secondary index table, it wouldn't help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Run it in the background.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Oct 1, 2008 4:42 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2008 20:48:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-from-bseg-performance/m-p/4493013#M1063331</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-18T20:48:21Z</dc:date>
    </item>
  </channel>
</rss>

