<?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: Selecting data from BSEG. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922953#M383329</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;remove the nested selects..

SELECT * FROM bseg INTO CORRESPONDING FIELDS OF table itab
WHERE matnr IN matnr
AND werks IN werks
AND bschl IN ('99' , '89' , '86' , '96')
AND ( ktosl IN ('BSX' , 'PRD')

OR sgtxt = 'Debit/credit to a material from a price change' ).

loop at itab into wa_itab.
SELECT SINGLE cpudt cputm budat blart bldat AWKEY FROM bkpf INTO CORRESPONDING FIELDS OF wa_itab
WHERE blart IN ('RE' , 'PR')
AND belnr = wa_itab-belnr.
modify itab from wa_itab.
clear wa_itab.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 24 Feb 2007 12:58:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-24T12:58:53Z</dc:date>
    <item>
      <title>Selecting data from BSEG.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922952#M383328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written one query to select data from BSEG table, but it is taking too much time to execute (40 sec per record) . I want to improve the performance of it. Please suggest the solutions. Query is below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM bseg INTO CORRESPONDING FIELDS OF wa_itab&lt;/P&gt;&lt;P&gt;                      WHERE matnr IN matnr&lt;/P&gt;&lt;P&gt;                        AND werks IN werks&lt;/P&gt;&lt;P&gt;                        AND bschl IN ('99' , '89' , '86' , '96')&lt;/P&gt;&lt;P&gt;                        AND ( ktosl IN ('BSX' , 'PRD')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                              OR sgtxt = 'Debit/credit to a material from a price change' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT SINGLE cpudt cputm budat blart bldat AWKEY FROM bkpf INTO CORRESPONDING FIELDS OF wa_itab&lt;/P&gt;&lt;P&gt;                        WHERE blart IN ('RE' , 'PR')&lt;/P&gt;&lt;P&gt;                        AND belnr = wa_itab-belnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  wa_itab-pperiod = wa_itab-budat(6).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  APPEND wa_itab TO itab.&lt;/P&gt;&lt;P&gt;  CLEAR wa_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should I create secondory index on bseg or something else?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Feb 2007 11:54:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922952#M383328</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-24T11:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from BSEG.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922953#M383329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;remove the nested selects..

SELECT * FROM bseg INTO CORRESPONDING FIELDS OF table itab
WHERE matnr IN matnr
AND werks IN werks
AND bschl IN ('99' , '89' , '86' , '96')
AND ( ktosl IN ('BSX' , 'PRD')

OR sgtxt = 'Debit/credit to a material from a price change' ).

loop at itab into wa_itab.
SELECT SINGLE cpudt cputm budat blart bldat AWKEY FROM bkpf INTO CORRESPONDING FIELDS OF wa_itab
WHERE blart IN ('RE' , 'PR')
AND belnr = wa_itab-belnr.
modify itab from wa_itab.
clear wa_itab.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Feb 2007 12:58:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922953#M383329</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-24T12:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from BSEG.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922954#M383330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Madan,&lt;/P&gt;&lt;P&gt;   Is there any typo in the code you have written here. Because both the SELECTS are filling the same work area WA_ITAB..&lt;/P&gt;&lt;P&gt;Please reply, &lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;Ravi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Feb 2007 20:01:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922954#M383330</guid>
      <dc:creator>raviprakash</dc:creator>
      <dc:date>2007-02-24T20:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from BSEG.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922955#M383331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BSEG is a cluster table, namely RFBLG. you won't be able to create index on such a table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And access with fields out of the tkeys ikf RFBLG BUKRS/BELNR/GJAHR/BUZEI risk to read the whole data table mapping the fields from cluster data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Look at &lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/cf/21f083446011d189700000e8322d00/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/cf/21f083446011d189700000e8322d00/content.htm&lt;/A&gt; for miore info on cluster table)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully there are "database indexes" on BSEG, which are actual database table : BSIS, BSAS, BSID, BSAS, and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	&lt;/P&gt;&lt;P&gt;BSEG Access&lt;/P&gt;&lt;P&gt;BSAD	Accounting: Secondary index for customers (cleared items)&lt;/P&gt;&lt;P&gt;BSAK	Accounting: Secondary index for vendors (cleared items)&lt;/P&gt;&lt;P&gt;BSAS	Accounting: Secondary index for G/L accounts (cleared items)&lt;/P&gt;&lt;P&gt;BSID	Accounting: Secondary index for customers&lt;/P&gt;&lt;P&gt;BSIK	Accounting: Secondary index for vendors&lt;/P&gt;&lt;P&gt;BSIM	Secondary Index, Documents for Material&lt;/P&gt;&lt;P&gt;BSIS	Accounting: Secondary index for G/L accounts&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case, as you need material posts, use BSIM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If some fields are missing you can then use a SELECT FOR ALL ENTRIES FROM BSEG/BKPF with the keys found in BSIM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Feb 2007 20:37:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922955#M383331</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2007-02-24T20:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from BSEG.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922956#M383332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;for bseg use all the primary key in the where clause to improve the performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward this with points.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Feb 2007 12:39:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922956#M383332</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-26T12:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from BSEG.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922957#M383333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1) In the above code avoid using SELECT...ENDSELECT (nested Select), instead use INTO TABLE&lt;/P&gt;&lt;P&gt;2) If possible change the order of fields in wa_itab and avoid using INTO CORRESPONDING FIELDS OF in the select statement.&lt;/P&gt;&lt;P&gt;3) BSEG is a table with huge number of fields. Donot use SELECT * ......, Select only required fields or columns&lt;/P&gt;&lt;P&gt;4) Bring the fetch for table BKPF outside the loop using SELECT ..... FOR ALL ENTRIES &lt;/P&gt;&lt;P&gt;5) If possible, try to use secondary index for table BKPF if available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;KK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Feb 2007 12:56:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/selecting-data-from-bseg/m-p/1922957#M383333</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-26T12:56:28Z</dc:date>
    </item>
  </channel>
</rss>

