<?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: Joining multiples tables with structure in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482382#M2001897</link>
    <description>&lt;P&gt;Okay, you probably read some obsolete discussions, myths, among which probably there were some true things but in very specific contexts. As a rule-of-thumb, you can use much more than 2 tables in a join, basically there's no reason to limit the number. Database systems are very much efficient, provided that you configure the database correctly.&lt;/P&gt;&lt;P&gt;For All Entries is no more recommended as rule-of-thumb, especially with high volumes.&lt;/P&gt;&lt;P&gt;(if you use FAE, don't forget to test IF it_final IS NOT INITIAL before SELECT, otherwise it will read the whole database table)&lt;/P&gt;&lt;P&gt;BINARY SEARCH should be avoided, use a SORTED or HASHED internal table instead.&lt;/P&gt;&lt;P&gt;BINARY SEARCH is prone to errors (in case the internal table has not been correctly sorted before searching). It's probably your error as I don't see any SORT (but if you use a SORTED or HASHED table, you won't have to SORT explicitly, nor use BINARY SEARCH).&lt;/P&gt;&lt;P&gt;Don't forget to select only texts in the current language (SY-LANGU).&lt;/P&gt;&lt;P&gt;And add IF sy-subrc = 0 after every read.&lt;/P&gt;&lt;P&gt;REUSE_ALV_GRID_DISPLAY should be considered obsolete. Instead, use CL_SALV_TABLE.&lt;/P&gt;</description>
    <pubDate>Sun, 20 Mar 2022 11:40:49 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2022-03-20T11:40:49Z</dc:date>
    <item>
      <title>Joining multiples tables with structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482377#M2001892</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;
  &lt;P&gt;I was practicing ABAP &amp;amp; need some help. I first did inner join between two tables &amp;amp; then was trying to add more tables by taking tables individually as its not good practice to take more than two tables in inner join &amp;amp; I am planning to use 7 tables. I have created structure &amp;amp; added fields there. At present I m getting G/L Description blank in output of report. I will be gradually adding more fields &amp;amp; tables.&lt;/P&gt;
  &lt;P&gt;Here is my code-&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;REPORT zven_details_test1.&lt;BR /&gt;TABLES: bkpf, acdoca, skat, cskt, cepct, lfa1, kna1, makt.&lt;BR /&gt;DATA: it_final TYPE TABLE OF zst_join_test,&lt;BR /&gt; wa_final TYPE zst_join_test.&lt;BR /&gt;DATA: wa_fcat TYPE slis_fieldcat_alv,&lt;BR /&gt; it_fcat TYPE slis_t_fieldcat_alv.&lt;BR /&gt;SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.&lt;BR /&gt; SELECT-OPTIONS: s_bukrs FOR bkpf-bukrs,&lt;BR /&gt; s_belnr FOR bkpf-belnr,&lt;BR /&gt; s_gjahr FOR bkpf-gjahr.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SELECTION-SCREEN END OF BLOCK b1.&lt;BR /&gt;&lt;BR /&gt;SELECT a~bukrs&lt;BR /&gt; a~belnr&lt;BR /&gt; a~gjahr&lt;BR /&gt; a~blart&lt;BR /&gt; a~bldat&lt;BR /&gt; a~budat&lt;BR /&gt; a~monat&lt;BR /&gt; a~awkey&lt;BR /&gt; a~awtyp&lt;BR /&gt; a~waers&lt;BR /&gt; b~awitem&lt;BR /&gt; b~rbukrs&lt;BR /&gt; b~rwcur&lt;BR /&gt; b~rhcur&lt;BR /&gt; b~rkcur&lt;BR /&gt; b~racct&lt;BR /&gt; b~rcntr&lt;BR /&gt; b~prctr&lt;BR /&gt; b~lifnr&lt;BR /&gt; b~kunnr&lt;BR /&gt; b~mwskz&lt;BR /&gt; b~wsl&lt;BR /&gt; b~hsl&lt;BR /&gt; b~ksl&lt;BR /&gt; b~matnr&lt;BR /&gt; b~rldnr&lt;BR /&gt;FROM bkpf as a&lt;BR /&gt;INNER JOIN acdoca AS b&lt;BR /&gt;ON a~bukrs = b~rbukrs AND&lt;BR /&gt;a~belnr = b~belnr AND&lt;BR /&gt;a~gjahr = b~gjahr&lt;BR /&gt;INTO TABLE it_final&lt;BR /&gt;WHERE a~bukrs IN s_bukrs&lt;BR /&gt;AND a~belnr IN s_belnr&lt;BR /&gt;AND a~gjahr IN s_gjahr.&lt;BR /&gt;&lt;BR /&gt;SELECT saknr, txt20 from skat&lt;BR /&gt;INTO TABLE @data(it_skat)&lt;BR /&gt;FOR ALL ENTRIES IN @it_final&lt;BR /&gt;WHERE saknr EQ @it_final-racct.&lt;BR /&gt;LOOP AT it_final into wa_final.&lt;BR /&gt;READ TABLE it_skat INTO data(wa_skat) WITH KEY saknr = wa_final-racct BINARY SEARCH.&lt;BR /&gt;wa_final-txt20 = wa_skat-txt20.&lt;BR /&gt;APPEND wa_final TO it_final.&lt;BR /&gt;CLEAR: wa_final, wa_skat.&lt;BR /&gt;ENDLOOP.&lt;BR /&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt; MESSAGE 'Records not found' TYPE 'I'.&lt;BR /&gt; LEAVE LIST-PROCESSING.&lt;BR /&gt;ENDIF.&lt;BR /&gt;DATA: lv_col TYPE i VALUE 0.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'&lt;BR /&gt; EXPORTING&lt;BR /&gt;* I_PROGRAM_NAME =&lt;BR /&gt;* I_INTERNAL_TABNAME =&lt;BR /&gt; i_structure_name = 'ZST_JOIN_TEST'&lt;BR /&gt;* I_CLIENT_NEVER_DISPLAY = 'X'&lt;BR /&gt;* I_INCLNAME =&lt;BR /&gt;* I_BYPASSING_BUFFER =&lt;BR /&gt;* I_BUFFER_ACTIVE =&lt;BR /&gt; CHANGING&lt;BR /&gt; ct_fieldcat = it_fcat&lt;BR /&gt;* EXCEPTIONS&lt;BR /&gt;* INCONSISTENT_INTERFACE = 1&lt;BR /&gt;* PROGRAM_ERROR = 2&lt;BR /&gt;* OTHERS = 3&lt;BR /&gt; .&lt;BR /&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt;* Implement suitable error handling here&lt;BR /&gt;ENDIF.&lt;BR /&gt;&lt;BR /&gt;CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'&lt;BR /&gt; EXPORTING&lt;BR /&gt; i_callback_program = sy-repid "Program name&lt;BR /&gt; i_callback_user_command = 'HANDLE_USER_COMMAND'&lt;BR /&gt; it_fieldcat = it_fcat&lt;BR /&gt; TABLES&lt;BR /&gt; t_outtab = it_final "Final output table&lt;BR /&gt; EXCEPTIONS&lt;BR /&gt; program_error = 1&lt;BR /&gt; OTHERS = 2.&lt;BR /&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt;* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;BR /&gt;* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;BR /&gt;* MESSAGE 'Report not Generated' TYPE 'I'.&lt;BR /&gt;ENDIF.&lt;BR /&gt;*ENDIF.&lt;BR /&gt;FORM handle_user_command USING r_ucomm LIKE sy-ucomm&lt;BR /&gt; rs_selfield TYPE slis_selfield.&lt;BR /&gt; IF r_ucomm EQ '&amp;amp;IC1'&lt;BR /&gt; AND rs_selfield-fieldname EQ 'BELNR'.&lt;BR /&gt; READ TABLE IT_final INTO DATA(wa_final_tmp) INDEX rs_selfield-tabindex.&lt;BR /&gt; IF sy-subrc EQ 0.&lt;BR /&gt; SET PARAMETER ID 'BLN' FIELD wa_final_tmp-belnr.&lt;BR /&gt; SET PARAMETER ID 'BUK' FIELD wa_final_tmp-bukrs.&lt;BR /&gt; SET PARAMETER ID 'GJR' FIELD wa_final_tmp-gjahr.&lt;BR /&gt; CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.&lt;BR /&gt; ENDIF.&lt;BR /&gt; ENDIF.&lt;BR /&gt;ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I m 100% sure that the issue is in my loop &amp;amp; read statement. I guess I know what to do when declaring all tables invidually but not sure how to do with structure. Here in my case the structure is zst_join_test.&lt;/P&gt;
  &lt;P&gt;Regards&lt;/P&gt;
  &lt;P&gt;Pankaj&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 05:39:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482377#M2001892</guid>
      <dc:creator>pankaj_adhikari</dc:creator>
      <dc:date>2022-03-20T05:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Joining multiples tables with structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482378#M2001893</link>
      <description>&lt;P&gt;Please edit your question: select your ABAP code and click the button CODE so that it's nicely displayed and we can read it easily.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 08:16:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482378#M2001893</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-03-20T08:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Joining multiples tables with structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482379#M2001894</link>
      <description>&lt;P&gt;Who said that it was not good practice to join more than 2 tables?&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 08:17:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482379#M2001894</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-03-20T08:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Joining multiples tables with structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482380#M2001895</link>
      <description>&lt;P&gt;What is your issue?&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 08:18:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482380#M2001895</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-03-20T08:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Joining multiples tables with structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482381#M2001896</link>
      <description>&lt;P&gt;Thanks Sandra. I have edited question so that it is in proper format. I read at many places it's not good practice to use inner join in more than 2 tables. My issue is I m not able to get data of G/L description. &lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pankaj&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 10:12:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482381#M2001896</guid>
      <dc:creator>pankaj_adhikari</dc:creator>
      <dc:date>2022-03-20T10:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Joining multiples tables with structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482382#M2001897</link>
      <description>&lt;P&gt;Okay, you probably read some obsolete discussions, myths, among which probably there were some true things but in very specific contexts. As a rule-of-thumb, you can use much more than 2 tables in a join, basically there's no reason to limit the number. Database systems are very much efficient, provided that you configure the database correctly.&lt;/P&gt;&lt;P&gt;For All Entries is no more recommended as rule-of-thumb, especially with high volumes.&lt;/P&gt;&lt;P&gt;(if you use FAE, don't forget to test IF it_final IS NOT INITIAL before SELECT, otherwise it will read the whole database table)&lt;/P&gt;&lt;P&gt;BINARY SEARCH should be avoided, use a SORTED or HASHED internal table instead.&lt;/P&gt;&lt;P&gt;BINARY SEARCH is prone to errors (in case the internal table has not been correctly sorted before searching). It's probably your error as I don't see any SORT (but if you use a SORTED or HASHED table, you won't have to SORT explicitly, nor use BINARY SEARCH).&lt;/P&gt;&lt;P&gt;Don't forget to select only texts in the current language (SY-LANGU).&lt;/P&gt;&lt;P&gt;And add IF sy-subrc = 0 after every read.&lt;/P&gt;&lt;P&gt;REUSE_ALV_GRID_DISPLAY should be considered obsolete. Instead, use CL_SALV_TABLE.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 11:40:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-multiples-tables-with-structure/m-p/12482382#M2001897</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-03-20T11:40:49Z</dc:date>
    </item>
  </channel>
</rss>

