<?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: JOIN ON put a condition in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449911#M1999409</link>
    <description>&lt;P&gt;Sandra thanks a lot. You also give me a solution to the above on , so the code is now &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ON ( ( @str_control_table-alter_ktopl = ' ' AND ska1~ktopl = skat~ktopl ) OR
     ( @str_control_table-alter_ktopl = 'X' AND skat~ktopl = @str_account_plan_data-companyinfo-chartcode ) ) AND
   ( ( @str_control_table-alter_ktopl = ' ' AND skat~saknr = skb1~saknr ) OR
     ( @str_control_table-alter_ktopl = 'X' AND skat~saknr = skb1~altkt ) ) AND
   skat~spras = 'G'&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The only thing that I do not know (and do not know if exists) is if there is no TXT50 with SPRAS = G then search with SPRAS = E.&lt;/P&gt;&lt;P&gt;For this reason I have the below LOOP after the SELECT&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    LOOP AT company_accounts ASSIGNING FIELD-SYMBOL(&amp;lt;wa_company_accounts&amp;gt;) WHERE txt50 = ''.
      SELECT SINGLE txt50 FROM skat
      WHERE ktopl = @main_chart_of_account AND
            saknr = @&amp;lt;wa_company_accounts&amp;gt;-saknr AND
            spras = 'E'
      INTO @&amp;lt;wa_company_accounts&amp;gt;-txt50.
    ENDLOOP.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sth that I do not like at all.&lt;/P&gt;&lt;P&gt;Again thanks&lt;/P&gt;</description>
    <pubDate>Sat, 26 Jun 2021 16:07:39 GMT</pubDate>
    <dc:creator>ekekakos</dc:creator>
    <dc:date>2021-06-26T16:07:39Z</dc:date>
    <item>
      <title>JOIN ON put a condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449908#M1999406</link>
      <description>&lt;P&gt;Hello can someone tell me if the below code is possible to be written in a way?&lt;/P&gt;
  &lt;P&gt;Namely, to have a condition in the ON of a JOIN&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;    SELECT CASE WHEN @str_control_table-alter_ktopl = 'X' THEN skb1~altkt
                WHEN @str_control_table-alter_ktopl = ' ' THEN ska1~saknr
           END AS saknr,
           skat~txt50,ska1~xbilk,skb1~mitkz, skb1~mwskz
      FROM ska1 
        INNER JOIN skb1
          ON ska1~saknr = skb1~saknr
        LEFT OUTER JOIN skat
          ON ska1~ktopl = skat~ktopl AND
             skat~saknr = @( COND #( WHEN str_control_table-alter_ktopl = ' ' THEN skb1~saknr
                                     WHEN str_control_table-alter_ktopl = 'X' THEN skb1~altkt ) ) AND
             skat~spras = 'G'
      WHERE ska1~ktopl = @main_chart_of_account AND
            ska1~saknr IN @select_options_structure-s_saknr AND
            skb1~bukrs = @select_options_structure-p_bukrs AND
            skb1~xloeb &amp;lt;&amp;gt; 'X' AND
            skb1~xspeb &amp;lt;&amp;gt; 'X' AND
            skb1~altkt &amp;lt;&amp;gt; ''
      INTO TABLE @company_accounts.
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;In the above code I have the following error: &lt;STRONG&gt;Class "ZCL_EB_CHART_OF_ACCOUNTS_MDL" does not contain an interface "SKB1"&lt;/STRONG&gt;.&lt;/P&gt;
  &lt;P&gt;Thanks&lt;/P&gt;
  &lt;P&gt;Elias&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 09:49:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449908#M1999406</guid>
      <dc:creator>ekekakos</dc:creator>
      <dc:date>2021-06-26T09:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: JOIN ON put a condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449909#M1999407</link>
      <description>&lt;P&gt;It's a good approach Elias, but I think it's not yet supported by ABAP SQL. Check out the below links with all the new enhancement to ABAP SQL.&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abennews-750-open_sql.htm#!ABAP_MODIFICATION_4@4@"&gt;New ABAP SQL Features&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, you have to write 2 Select statements based on the condition.First, you have to select the data from skb1 . Then second select query with the text able sakt.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT CASE WHEN @str_control_table-alter_ktopl = 'X' THEN skb1~altkt
             WHEN @str_control_table-alter_ktopl = ' ' THEN ska1~saknr
        END AS saknr,
        skat~txt50,ska1~xbilk,skb1~mitkz, skb1~mwskz
   FROM ska1
     INNER JOIN skb1
       ON ska1~saknr = skb1~saknr
   WHERE ska1~ktopl = @main_chart_of_account AND
         ska1~saknr IN @select_options_structure-s_saknr AND
         skb1~bukrs = @select_options_structure-p_bukrs AND
         skb1~xloeb &amp;lt;&amp;gt; 'X' AND
         skb1~xspeb &amp;lt;&amp;gt; 'X' AND
         skb1~altkt &amp;lt;&amp;gt; ''
   INTO TABLE @DATA(company_accounts).

IF company_accounts IS NOT INITIAL.

  SELECT saknr, skat~txt50
    FROM sakt
     FOR ALL ENTRIES IN company_accounts
   WHERE saknr = company_accounts-saknr
    AND  skat~spras = 'G'.

ENDIF.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Gourab&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 12:25:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449909#M1999407</guid>
      <dc:creator>Gourab_Dey</dc:creator>
      <dc:date>2021-06-26T12:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: JOIN ON put a condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449910#M1999408</link>
      <description>&lt;P&gt;Inside a Host Expression (@( ... )), you can only use ABAP, not ABAP SQL syntax (i.e. table~column cannot appear inside it + you can't use any SQL function, etc.)&lt;/P&gt;&lt;P&gt;Because you need to use table~column, you must use ABAP SQL exclusively, one workaround is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;...
  AND ( ( @str_control_table-alter_ktopl = ' ' AND skat~saknr = skb1~saknr )
     OR ( @str_control_table-alter_ktopl = 'X' AND skat~saknr = skb1~altkt ) )
...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(if str_control_table-alter_ktopl equals ' ', the SQL statement sent to the database will be AND ( ( ' ' = ' ' AND skat~saknr = skb1~saknr ) OR ( ' ' = 'X' AND skat~saknr = skb1~altkt ) ))&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 12:49:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449910#M1999408</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-06-26T12:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: JOIN ON put a condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449911#M1999409</link>
      <description>&lt;P&gt;Sandra thanks a lot. You also give me a solution to the above on , so the code is now &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ON ( ( @str_control_table-alter_ktopl = ' ' AND ska1~ktopl = skat~ktopl ) OR
     ( @str_control_table-alter_ktopl = 'X' AND skat~ktopl = @str_account_plan_data-companyinfo-chartcode ) ) AND
   ( ( @str_control_table-alter_ktopl = ' ' AND skat~saknr = skb1~saknr ) OR
     ( @str_control_table-alter_ktopl = 'X' AND skat~saknr = skb1~altkt ) ) AND
   skat~spras = 'G'&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The only thing that I do not know (and do not know if exists) is if there is no TXT50 with SPRAS = G then search with SPRAS = E.&lt;/P&gt;&lt;P&gt;For this reason I have the below LOOP after the SELECT&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    LOOP AT company_accounts ASSIGNING FIELD-SYMBOL(&amp;lt;wa_company_accounts&amp;gt;) WHERE txt50 = ''.
      SELECT SINGLE txt50 FROM skat
      WHERE ktopl = @main_chart_of_account AND
            saknr = @&amp;lt;wa_company_accounts&amp;gt;-saknr AND
            spras = 'E'
      INTO @&amp;lt;wa_company_accounts&amp;gt;-txt50.
    ENDLOOP.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sth that I do not like at all.&lt;/P&gt;&lt;P&gt;Again thanks&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 16:07:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449911#M1999409</guid>
      <dc:creator>ekekakos</dc:creator>
      <dc:date>2021-06-26T16:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: JOIN ON put a condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449912#M1999410</link>
      <description>&lt;P&gt;Gourab thanks but I think that sth is missing.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 16:08:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449912#M1999410</guid>
      <dc:creator>ekekakos</dc:creator>
      <dc:date>2021-06-26T16:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: JOIN ON put a condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449913#M1999411</link>
      <description>&lt;P&gt;I agree, I don't like it at all, too. Instead, you could use a second LEFT OUTER JOIN skat on SPRAS = 'E' (so, you also need to use table aliases to differentiate the columns from the "two SKAT"), and in your ABAP code, you will take the 'G' or 'E' text column as you wish.&lt;/P&gt;&lt;P&gt;It makes a complex SELECT. If you want to simplify it by using skat~spras IN ('G','E'), add the condition AND skat~txt50 IS NOT NULL in the WHERE clause, but you may get duplicate lines if texts exist in both Greek and English languages that you will need to remove with for instance a SORT company_accounts BY saknr spras descending so that 'G' appears  'E', followed by a DELETE ADJACENT DUPLICATES FROM company_accounts COMPARING saknr.&lt;/P&gt;&lt;P&gt;(something like that)&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 19:38:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-on-put-a-condition/m-p/12449913#M1999411</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-06-26T19:38:00Z</dc:date>
    </item>
  </channel>
</rss>

