<?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: problem joining 5 tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-joining-5-tables/m-p/2225666#M478239</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok.. i'll make some changes but.... the join sentence i don't know how to do it properly, i've done it as it was done before... no primary key fields...i have done a nested loop because i thought there could be more than one registry for an entry in it_materiales...&lt;/P&gt;&lt;P&gt;and the biggest doubt i have is why it_tpik3 has no data aftee the "select .. for all entries in it_materiales.." ??&lt;/P&gt;&lt;P&gt;thanks...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Apr 2007 08:08:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-04-26T08:08:36Z</dc:date>
    <item>
      <title>problem joining 5 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-joining-5-tables/m-p/2225664#M478237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have to modify a report because it goes too slow.. the problem is when joining 5 tables, i'm trying to change it but i'm a little bit "lost".... the original code is de following..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT DISTINCT a&lt;SUB&gt;aufnr a&lt;/SUB&gt;auart a&lt;SUB&gt;erdat a&lt;/SUB&gt;ktext a~werks&lt;/P&gt;&lt;P&gt;         b&lt;SUB&gt;acpos b&lt;/SUB&gt;objnr&lt;/P&gt;&lt;P&gt;         c&lt;SUB&gt;kokrs c&lt;/SUB&gt;acpos&lt;/P&gt;&lt;P&gt;         d&lt;SUB&gt;bwart d&lt;/SUB&gt;budat d&lt;SUB&gt;mblnr d&lt;/SUB&gt;mjahr d&lt;SUB&gt;zeile d&lt;/SUB&gt;erfmg d~erfme&lt;/P&gt;&lt;P&gt;         d&lt;SUB&gt;matnr e&lt;/SUB&gt;maktx d&lt;SUB&gt;aufnr d&lt;/SUB&gt;dmbtr d&lt;SUB&gt;kokrs d&lt;/SUB&gt;sakto&lt;/P&gt;&lt;P&gt;  INTO TABLE it_materiales&lt;/P&gt;&lt;P&gt;  FROM ( aufk AS a&lt;/P&gt;&lt;P&gt;         INNER JOIN pmco AS b&lt;/P&gt;&lt;P&gt;         ON  b&lt;SUB&gt;objnr = a&lt;/SUB&gt;objnr&lt;/P&gt;&lt;P&gt;         INNER JOIN tpik3 AS c&lt;/P&gt;&lt;P&gt;         ON  c&lt;SUB&gt;kokrs = a&lt;/SUB&gt;kokrs&lt;/P&gt;&lt;P&gt;         AND c&lt;SUB&gt;acpos = b&lt;/SUB&gt;acpos&lt;/P&gt;&lt;P&gt;         INNER JOIN aufm AS d&lt;/P&gt;&lt;P&gt;         ON  d&lt;SUB&gt;aufnr = a&lt;/SUB&gt;aufnr&lt;/P&gt;&lt;P&gt;         AND d&lt;SUB&gt;kokrs = c&lt;/SUB&gt;kokrs&lt;/P&gt;&lt;P&gt;         AND d&lt;SUB&gt;sakto = c&lt;/SUB&gt;kstrf&lt;/P&gt;&lt;P&gt;         INNER JOIN makt AS e&lt;/P&gt;&lt;P&gt;         ON e&lt;SUB&gt;matnr = d&lt;/SUB&gt;matnr )&lt;/P&gt;&lt;P&gt;       WHERE a~aufnr IN s_aufnr AND&lt;/P&gt;&lt;P&gt;             a~auart IN s_auart AND&lt;/P&gt;&lt;P&gt;             a~werks IN s_iwerk AND&lt;/P&gt;&lt;P&gt;             b~acpos IN s_acpos AND&lt;/P&gt;&lt;P&gt;             d~budat IN s_budat AND&lt;/P&gt;&lt;P&gt;             e~spras = sy-langu.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to make it go quicklier, i did this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA: it_aufm LIKE aufm OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;        it_tpik3 LIKE tpik3 OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;        it_aux LIKE it_materiales OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;        wa_material LIKE it_materiales.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT DISTINCT a&lt;SUB&gt;aufnr a&lt;/SUB&gt;auart a&lt;SUB&gt;erdat a&lt;/SUB&gt;ktext a~werks&lt;/P&gt;&lt;P&gt;         b&lt;SUB&gt;acpos b&lt;/SUB&gt;objnr&lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF TABLE it_materiales&lt;/P&gt;&lt;P&gt;  FROM ( aufk AS a&lt;/P&gt;&lt;P&gt;         INNER JOIN pmco AS b&lt;/P&gt;&lt;P&gt;         ON  b&lt;SUB&gt;objnr = a&lt;/SUB&gt;objnr )&lt;/P&gt;&lt;P&gt;       WHERE a~aufnr IN s_aufnr AND&lt;/P&gt;&lt;P&gt;             a~auart IN s_auart AND&lt;/P&gt;&lt;P&gt;             a~werks IN s_iwerk AND&lt;/P&gt;&lt;P&gt;             b~acpos IN s_acpos.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT * INTO TABLE it_tpik3&lt;/P&gt;&lt;P&gt;    FROM tpik3&lt;/P&gt;&lt;P&gt;    FOR ALL ENTRIES IN it_materiales&lt;/P&gt;&lt;P&gt;      WHERE kokrs = it_materiales-kokrs&lt;/P&gt;&lt;P&gt;        AND acpos = it_materiales-acpos.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT it_materiales INTO wa_material.&lt;/P&gt;&lt;P&gt;    LOOP AT it_tpik3 WHERE kokrs = wa_material-kokrs&lt;/P&gt;&lt;P&gt;                       AND acpos = wa_material-acpos.&lt;/P&gt;&lt;P&gt;      MOVE-CORRESPONDING wa_material TO it_aux.&lt;/P&gt;&lt;P&gt;      MOVE-CORRESPONDING it_tpik3 TO it_aux.&lt;/P&gt;&lt;P&gt;      APPEND it_aux.&lt;/P&gt;&lt;P&gt;      CLEAR it_aux.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  it_materiales[] = it_aux[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT it_materiales.&lt;/P&gt;&lt;P&gt;    READ TABLE it_aufm WITH KEY aufnr = it_materiales-aufnr&lt;/P&gt;&lt;P&gt;                                kokrs = it_materiales-kokrs&lt;/P&gt;&lt;P&gt;                                sakto = it_materiales-kstrf.&lt;/P&gt;&lt;P&gt;    IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      IF it_aufm-budat NOT IN s_budat.&lt;/P&gt;&lt;P&gt;        DELETE it_materiales.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;        SELECT SINGLE maktx&lt;/P&gt;&lt;P&gt;          FROM makt&lt;/P&gt;&lt;P&gt;            INTO it_materiales-maktx&lt;/P&gt;&lt;P&gt;              WHERE matnr = it_materiales-matnr&lt;/P&gt;&lt;P&gt;                AND spras = sy-langu.&lt;/P&gt;&lt;P&gt;        MODIFY it_materiales.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when acceding table TPIK3 i get no data.... i know i'm doing something wrong but don't know where.... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance !!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2007 07:26:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-joining-5-tables/m-p/2225664#M478237</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-26T07:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: problem joining 5 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-joining-5-tables/m-p/2225665#M478238</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;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. check join conditions properly.&lt;/P&gt;&lt;P&gt;2. do not use use nested loop command s like&lt;/P&gt;&lt;P&gt;LOOP AT it_materiales INTO wa_material.&lt;/P&gt;&lt;P&gt;LOOP AT it_tpik3 WHERE kokrs = wa_material-kokrs&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;instead use.&lt;/P&gt;&lt;P&gt;loop at it_material..&lt;/P&gt;&lt;P&gt;read table it_tpik3 with key....&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;3. do not use CORROSPONDING FIELDS option!!!&lt;/P&gt;&lt;P&gt;4. donot use select single in loop, instead fetch all records once in itabl using for all entries.&lt;/P&gt;&lt;P&gt;5. check data of it_material with these condition in table tpik3 : &lt;/P&gt;&lt;P&gt;WHERE kokrs = it_materiales-kokrs&lt;/P&gt;&lt;P&gt;AND acpos = it_materiales-acpos.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jogdand M B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2007 07:47:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-joining-5-tables/m-p/2225665#M478238</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-26T07:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: problem joining 5 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-joining-5-tables/m-p/2225666#M478239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok.. i'll make some changes but.... the join sentence i don't know how to do it properly, i've done it as it was done before... no primary key fields...i have done a nested loop because i thought there could be more than one registry for an entry in it_materiales...&lt;/P&gt;&lt;P&gt;and the biggest doubt i have is why it_tpik3 has no data aftee the "select .. for all entries in it_materiales.." ??&lt;/P&gt;&lt;P&gt;thanks...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2007 08:08:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-joining-5-tables/m-p/2225666#M478239</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-26T08:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: problem joining 5 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-joining-5-tables/m-p/2225667#M478240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;If you are access 5 database table with join, it will affect performance of the report. It always recommand that select from main table and use 'FOR ALL ENTRIES' and then manipulate the information as per required using loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nilesh Shete&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2007 08:11:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-joining-5-tables/m-p/2225667#M478240</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-26T08:11:11Z</dc:date>
    </item>
  </channel>
</rss>

