<?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 Most optimized select query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/most-optimized-select-query/m-p/1062524#M92303</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends ,&lt;/P&gt;&lt;P&gt;Please suggest most optimized code for the following scenerio , which fetches Billing Document , Company Code , and Address based on plant&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two tables &lt;/P&gt;&lt;P&gt;1 . T001 (only 13 rows present in this) containing &lt;/P&gt;&lt;P&gt;a. Company Code - BUKRS&lt;/P&gt;&lt;P&gt;b. Address - ADRNR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. BSEG (60000 rows present in this and 3000 rows per plant on avg. ) containing&lt;/P&gt;&lt;P&gt;a. Billing document - VBELN &lt;/P&gt;&lt;P&gt;b. Planning Date -  FDTAG&lt;/P&gt;&lt;P&gt;c. Company Code - BUKRS&lt;/P&gt;&lt;P&gt;d. Plant - WERKS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 04 Feb 2024 01:17:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2024-02-04T01:17:34Z</dc:date>
    <item>
      <title>Most optimized select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/most-optimized-select-query/m-p/1062524#M92303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends ,&lt;/P&gt;&lt;P&gt;Please suggest most optimized code for the following scenerio , which fetches Billing Document , Company Code , and Address based on plant&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two tables &lt;/P&gt;&lt;P&gt;1 . T001 (only 13 rows present in this) containing &lt;/P&gt;&lt;P&gt;a. Company Code - BUKRS&lt;/P&gt;&lt;P&gt;b. Address - ADRNR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. BSEG (60000 rows present in this and 3000 rows per plant on avg. ) containing&lt;/P&gt;&lt;P&gt;a. Billing document - VBELN &lt;/P&gt;&lt;P&gt;b. Planning Date -  FDTAG&lt;/P&gt;&lt;P&gt;c. Company Code - BUKRS&lt;/P&gt;&lt;P&gt;d. Plant - WERKS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Feb 2024 01:17:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/most-optimized-select-query/m-p/1062524#M92303</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2024-02-04T01:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Most optimized select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/most-optimized-select-query/m-p/1062525#M92304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Yogesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRy this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select bukrs, adrnr into table i_tab1 from t001.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt; Select vbeln bukrs werks into table i_tab2 from bseg &lt;/P&gt;&lt;P&gt;  for all entries in i_tab1 where bukrs = i_tab1-bukrs.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use these two internal tables after proper sorting to get your required output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Nov 2005 08:10:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/most-optimized-select-query/m-p/1062525#M92304</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-11-24T08:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Most optimized select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/most-optimized-select-query/m-p/1062526#M92305</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;secify the selection criteria&lt;/P&gt;&lt;P&gt;select bukrs werks adrnr from t001 into table itab_company&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc is initial.  &lt;/P&gt;&lt;P&gt;select bukrs belnr gjahr &lt;/P&gt;&lt;P&gt;  into table itab&lt;/P&gt;&lt;P&gt;  from bseg&lt;/P&gt;&lt;P&gt;  for all entries in itab_company&lt;/P&gt;&lt;P&gt;  where bukrs = itab_company-bukrs&lt;/P&gt;&lt;P&gt;  and werks = itab_Company-werks&lt;/P&gt;&lt;P&gt;  and.......anymore conditions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select name1 name2 from adrc into table itab_address &lt;/P&gt;&lt;P&gt;  for all entries in itab_company&lt;/P&gt;&lt;P&gt;where adrnr = itab_company-adrnr&lt;/P&gt;&lt;P&gt;endif&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Nov 2005 08:16:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/most-optimized-select-query/m-p/1062526#M92305</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-11-24T08:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Most optimized select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/most-optimized-select-query/m-p/1062527#M92306</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;  As far as possible avoid retrieving data from BSEG as this is a cluster table, instead you can use the following according to your requirement,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. To get Vendor account details,&lt;/P&gt;&lt;P&gt;Use: BSAK(Cleared)&lt;/P&gt;&lt;P&gt;     BSIK(Open) you may have to append both the table entries in one internal table, using appending statement&lt;/P&gt;&lt;P&gt;2.To get G/L account details,&lt;/P&gt;&lt;P&gt;Use: BSAS(Cleared)&lt;/P&gt;&lt;P&gt;     BSIS(Open)&lt;/P&gt;&lt;P&gt;3.To get Customer account details&lt;/P&gt;&lt;P&gt;Use: BSAD(Cleared)&lt;/P&gt;&lt;P&gt;     BSIS(Open)&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Nov 2005 08:35:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/most-optimized-select-query/m-p/1062527#M92306</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-11-24T08:35:18Z</dc:date>
    </item>
  </channel>
</rss>

