<?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 left join between two tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279071#M1988588</link>
    <description>&lt;P&gt;to get only the data from the left table I have to use a right left join? &lt;/P&gt;
  &lt;P&gt;this is the code: &lt;/P&gt;
  &lt;P&gt; select * &lt;/P&gt;
  &lt;P&gt; from marc &lt;/P&gt;
  &lt;P&gt;left outer join mseg on marc ~ matnr = mseg ~ matnr and marc ~ werks = mseg ~ werks &lt;/P&gt;
  &lt;P&gt;into CORRESPONDING FIELDS OF TABLE it_marc &lt;/P&gt;
  &lt;P&gt;WHERE marc ~ WERKS in s_plant and mseg ~ CPUTM_MKPF&amp;gt; = sy-uzeit. .&lt;/P&gt;
  &lt;P&gt; gives me this error:&lt;/P&gt;
  &lt;P&gt; If new Open SQL syntax is used, all host variables must be escaped using @. The variable S_PLANT is not escaped.&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jul 2020 13:23:45 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2020-07-24T13:23:45Z</dc:date>
    <item>
      <title>left join between two tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279071#M1988588</link>
      <description>&lt;P&gt;to get only the data from the left table I have to use a right left join? &lt;/P&gt;
  &lt;P&gt;this is the code: &lt;/P&gt;
  &lt;P&gt; select * &lt;/P&gt;
  &lt;P&gt; from marc &lt;/P&gt;
  &lt;P&gt;left outer join mseg on marc ~ matnr = mseg ~ matnr and marc ~ werks = mseg ~ werks &lt;/P&gt;
  &lt;P&gt;into CORRESPONDING FIELDS OF TABLE it_marc &lt;/P&gt;
  &lt;P&gt;WHERE marc ~ WERKS in s_plant and mseg ~ CPUTM_MKPF&amp;gt; = sy-uzeit. .&lt;/P&gt;
  &lt;P&gt; gives me this error:&lt;/P&gt;
  &lt;P&gt; If new Open SQL syntax is used, all host variables must be escaped using @. The variable S_PLANT is not escaped.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 13:23:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279071#M1988588</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-07-24T13:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: left join between two tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279072#M1988589</link>
      <description>&lt;P&gt;Hello &lt;SPAN class="mention-scrubbed"&gt;nick99999&lt;/SPAN&gt;, &lt;/P&gt;&lt;P&gt;You just have to use inner join which is left inner join by default. Error is due to missing @ symbol on all variables used which is the principle while using open SQL statements. Below code for your reference, &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select *
from marc
Inner join mseg 
on marc ~ matnr = mseg ~ matnr and marc ~ werks = mseg ~ werks
into CORRESPONDING FIELDS OF TABLE @it_marc
WHERE marc ~ WERKS in @s_plant and mseg ~ CPUTM_MKPF&amp;gt; = @sy-uzeit. .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards! &lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 13:50:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279072#M1988589</guid>
      <dc:creator>former_member1716</dc:creator>
      <dc:date>2020-07-24T13:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: left join between two tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279073#M1988590</link>
      <description>&lt;P&gt;does this just take the data from the marc table?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 13:53:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279073#M1988590</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-07-24T13:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: left join between two tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279074#M1988591</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;nick99999&lt;/SPAN&gt; because of the presence of CORRESPONDING FIELDS, it depends on what component names are declared in IT_MARC. If you have one component with the same name as one column from MSEG, then it will read this column. But if you don't have any component with the same name as a column from MSEG, then MSEG won't be read.&lt;/P&gt;&lt;P&gt;(and that means of course that you must use component names with the names of columns from MARC to read data from MARC)&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 15:13:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279074#M1988591</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-07-24T15:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: left join between two tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279075#M1988592</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;the it_marc table is the same as the marc table.
I'm only interested in the values of the marc table,
because for example using the filters in se16 in the marc there is only one corresponding row (and I want my internal table to have only that row) while in the mseg there are 36 rows.
in the select it brings me all 36 rows when I just want one of the marc table&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 15:30:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279075#M1988592</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-07-24T15:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: left join between two tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279076#M1988593</link>
      <description>&lt;P&gt;What you're looking for doesn't imply a JOIN, it implies EXISTS:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA dummy_plant TYPE marc-werks.
SELECT-OPTIONS s_plant FOR dummy_plant.
DATA it_marc TYPE TABLE OF marc.
SELECT * FROM marc
  WHERE marc~werks IN @s_plant
    AND EXISTS (
      SELECT * FROM mseg
      WHERE marc~matnr = mseg~matnr
        AND marc~werks = mseg~werks
        AND mseg~cputm_mkpf &amp;gt;= @sy-uzeit )
 INTO TABLE @it_marc. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;By the way, it seems obvious to me that you should test both CPUTM_MKPF and CPUDT_MKPF:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AND ( mseg~CPUDT_MKPF &amp;gt; @sy-datum
   OR ( mseg~CPUDT_MKPF = @sy-datum
    AND mseg~cputm_mkpf &amp;gt;= @sy-uzeit ) )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;NB: I removed CORRESPONDING FIELDS because the target data object has the same structure as the database table.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 15:43:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/left-join-between-two-tables/m-p/12279076#M1988593</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-07-24T15:43:47Z</dc:date>
    </item>
  </channel>
</rss>

