<?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: [SQL/ABAP] Best practice for selection in multiple tables ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575197#M22530</link>
    <description>&lt;P&gt;Don't forget, in case of join, to remove duplicates.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Dec 2017 15:38:33 GMT</pubDate>
    <dc:creator>RaymondGiuseppi</dc:creator>
    <dc:date>2017-12-07T15:38:33Z</dc:date>
    <item>
      <title>[SQL/ABAP] Best practice for selection in multiple tables ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575192#M22525</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hello everybody, &lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;I would like to know what is the best practice to select data in several tables that are linked by keys and exploit the result of each table individually. &lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Example&lt;/STRONG&gt;: What is the best practice that goes on between ************************* &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;data: lt_mast standard type table of mast,         
      lt_stko standard type table of stko,
      lt_stpo standard type table of stpo,
      lt_draw standard type table of draw.


*************************
* what is the best practice for filling lt_mast (for example werks 0001), lt* _stko (bound in mast-matnr), lt_stpo (bound in stko-stlnr / stko-stlty * * * ...), lt_draw (bound in stpo-doknr).


select * from mast where " ...

loop at lt_mast " ...
 " constuction of a range lr_matnr
endloop.


select * from where matnr in lr_matnr " ...


loop at stko into ls_stko.
" I can not do range on two related fields ..
" if not another request on stpo in join on stpo ...
  select * from stpo appending table lt_stpo where
  stlnr = ls_stko-stlnr and stlty = ls_stko-stlty.
endloop
" etc ...
" we can not make a single query that will fill all tables at once / or a b" " i" g join that can be split into each table? ... ?? I need help
*************************

" lt_mast lt .... filled tables

Thanks a lot !&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 17:54:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575192#M22525</guid>
      <dc:creator>thibault_gauthier</dc:creator>
      <dc:date>2017-12-06T17:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: [SQL/ABAP] Best practice for selection in multiple tables ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575193#M22526</link>
      <description>&lt;P&gt;I would suggest :&lt;/P&gt;
  &lt;UL&gt;
   &lt;LI&gt;Check if you can get the required Output by using the "BOM API's", such as FM "CS_BOM_EXPL_MAT_V2" / "CSAP_MAT_BOM_READ" / "CAVC_C_GET_BOM_HEADER_DATA" / "CAVC_C_GET_BOM_ITEM_DATA" ...&lt;/LI&gt;
   &lt;LI&gt;Found a Report that uses MAST - STKO - STPO - STAS : &lt;A href="https://www.scribd.com/document/206374841/Bom-Report-using-stko-stpo-stas-mast-table" target="_blank"&gt;link&lt;/A&gt;&lt;/LI&gt;
   &lt;LI&gt;Some old content on SDN (.PDF "BOM Header and Item Extraction in SAP - Business Intelligence") : &lt;A href="https://archive.sap.com/kmuuid2/b0af489e-72b1-2b10-159d-abb8058fb88d/BOM%20Header%20and%20Item%20Extraction%20in%20SAP%20-%20Business%20Intelligence.pdf" target="_blank"&gt;link&lt;/A&gt;&lt;/LI&gt;
  &lt;/UL&gt;
  &lt;P&gt;&lt;BR /&gt;I hope this helps ...&lt;/P&gt;
  &lt;P&gt;Kind regards&lt;/P&gt;
  &lt;P&gt;Nic T.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 21:43:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575193#M22526</guid>
      <dc:creator>NTeunckens</dc:creator>
      <dc:date>2017-12-06T21:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: [SQL/ABAP] Best practice for selection in multiple tables ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575194#M22527</link>
      <description>&lt;P&gt;If you're on 7.40 SP08 or higher you can do this:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;SELECT stko~*, stpo~*
  INTO TABLE @DATA(lt)
  FROM stko JOIN stpo ON stko~stlnr = stpo~stlnr
                     AND stko~stlty = stpo~stlty.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Table &lt;STRONG&gt;lt&lt;/STRONG&gt; will be created with structure&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;TYPES:BEGIN OF ztype,
       stko TYPE stko,
       stpo TYPE stpo,
      END OF ztype.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;So now you just loop at lt and fill your tables&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;LOOP AT lt INTO ls.
  APPEND ls-stko TO lt_stko.
  APPEND ls-stpo TO lt_stpo.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Dec 2017 05:08:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575194#M22527</guid>
      <dc:creator>former_member210008</dc:creator>
      <dc:date>2017-12-07T05:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: [SQL/ABAP] Best practice for selection in multiple tables ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575195#M22528</link>
      <description>&lt;P&gt;General answer: always prefer a join. Make sure to use the indexes (if not, ask the database expert). It also dépends on the quantity of data you need to extract. Then a database expert does performance tests on real data and adjusts the query if necessary, or adjusts things on the database (index, statistics, etc.), and sometimes a rewrite of some portions of the program may be needed.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 07:57:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575195#M22528</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2017-12-07T07:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: [SQL/ABAP] Best practice for selection in multiple tables ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575196#M22529</link>
      <description>&lt;P&gt;Thank you very much this is exactly the kind of things I searched for !&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 08:46:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575196#M22529</guid>
      <dc:creator>thibault_gauthier</dc:creator>
      <dc:date>2017-12-07T08:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: [SQL/ABAP] Best practice for selection in multiple tables ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575197#M22530</link>
      <description>&lt;P&gt;Don't forget, in case of join, to remove duplicates.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2017 15:38:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575197#M22530</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2017-12-07T15:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: [SQL/ABAP] Best practice for selection in multiple tables ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575198#M22531</link>
      <description>&lt;P&gt;Yes, I took a little time to understand the exact operation, with the inner joins, external left / right. And it's true that we can end up with a lot of recordings !&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 10:08:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-abap-best-practice-for-selection-in-multiple-tables/m-p/575198#M22531</guid>
      <dc:creator>thibault_gauthier</dc:creator>
      <dc:date>2017-12-12T10:08:44Z</dc:date>
    </item>
  </channel>
</rss>

