<?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: Abap SQL question in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575857#M1565842</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IS NULL results in bypass of buffer and full database table scan, as I recall SAP's documentation on this usage....check out &lt;STRONG&gt;subquery&lt;/STRONG&gt;, from &lt;STRONG&gt;tips and tricks&lt;/STRONG&gt; feature in transaction SE30 for possible alternative (and stunningly fast) check against another table, which can be used to verify exists or not exists.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Jan 2011 13:23:08 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-01-26T13:23:08Z</dc:date>
    <item>
      <title>Abap SQL question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575854#M1565839</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;I need to select the set of records only in Table A, but not in Table B. I think that the correct SQL is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select k~vbeln&lt;/P&gt;&lt;P&gt;into data&lt;/P&gt;&lt;P&gt;from vbak as k &lt;/P&gt;&lt;P&gt;inner join vbfa as f on k&lt;SUB&gt;vbeln = f&lt;/SUB&gt;vbelv&lt;/P&gt;&lt;P&gt;where f~vbelv is null.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the following message appears: u201CNo fields from the right-hand table of a LEFT OUTER JOIN may appear in the WHERE condition: u201CF~VBELBu201Du201D.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ricard.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 08:47:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575854#M1565839</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T08:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Abap SQL question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575855#M1565840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Oscar, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried your coding and I don't see anything wrong with it. For that query, I wrote it like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPES : BEGIN OF ty_data, 
          vbeln TYPE vbak-vbeln, 
        END OF ty_data.

DATA : lw_data TYPE ty_data. 

SELECT a~vbeln
       INTO lw_data
       FROM vbak AS a
       INNER JOIN vbfa AS b ON a~vbeln = b~vbelv
       WHERE b~vbelv IS NULL.
    &amp;lt;you can do your process here&amp;gt;
ENDSELECT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Probably you need to check your variables declarations again... see if you are declaring correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;William Wilstroth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: william wilstroth on Jan 26, 2011 5:04 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 09:03:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575855#M1565840</guid>
      <dc:creator>Wil_Wilstroth</dc:creator>
      <dc:date>2011-01-26T09:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Abap SQL question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575856#M1565841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry!!! it is not an inner join, is a left join. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: str type string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select k~vbeln&lt;/P&gt;&lt;P&gt;into str&lt;/P&gt;&lt;P&gt;from vbak as k&lt;/P&gt;&lt;P&gt;left join vbfa as f on k&lt;SUB&gt;vbeln = f&lt;/SUB&gt;vbelv&lt;/P&gt;&lt;P&gt;where f~vbelv is null.&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ricard.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 12:32:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575856#M1565841</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T12:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: Abap SQL question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575857#M1565842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IS NULL results in bypass of buffer and full database table scan, as I recall SAP's documentation on this usage....check out &lt;STRONG&gt;subquery&lt;/STRONG&gt;, from &lt;STRONG&gt;tips and tricks&lt;/STRONG&gt; feature in transaction SE30 for possible alternative (and stunningly fast) check against another table, which can be used to verify exists or not exists.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 13:23:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575857#M1565842</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T13:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Abap SQL question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575858#M1565843</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 out this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

select a~vbeln a~ernam into corresponding fields of table it_vbak
  from vbfa as b inner join vbak as a on b~vbelv = a~vbeln
    where b~vbelv is null.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Anmol.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: anmol112 on Jan 26, 2011 8:27 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 13:26:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575858#M1565843</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T13:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Abap SQL question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575859#M1565844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Oscar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think your query is wrong.&lt;/P&gt;&lt;P&gt;*I need to select the set of records only in Table A, but not in Table B. *&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming u want records in vbak that are not in vbfa&lt;/P&gt;&lt;P&gt;The correct SQL is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select vbeln 
into data
from vbak 
where vbeln not in (select vbeln from vbfa)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This below query will give you a list of vbeln that are present in both vbak and vbfa and whose vbelv is not null.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select k~vbeln
into data
from vbak as k
inner join vbfa as f on k~vbeln = f~vbelv
where f~vbelv is null.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jovito&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 14:18:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575859#M1565844</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T14:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Abap SQL question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575860#M1565845</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;PRE&gt;&lt;CODE&gt;I need to select the set of records only in Table A, but not in Table B. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is the case then i think Jovito is correct,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else you can try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select vbelv from vbfa into corresponding fields of table it_vbfa.
if it_vbfa is not initial.
select vbeln into corresponding fields of table it_vbak
    from vbak for all entries in it_vbfa
       where vbeln ne it_vbfa-vbelv.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 14:49:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575860#M1565845</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-26T14:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Abap SQL question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575861#M1565846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Oscar &amp;amp; William,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;first of all: The database meaning of NULL is that for the field in question no value is stored for an existing record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SAP tables we rarely have any NULL values. Only if you extend an existing table, i.e. append a new field, the database will expand the structure but not store INITIAL values for the new field in all records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second, just a hint: although the SAP example uses the mystifying ALIAS (AS) addition for joins, it does not help except reducing the code transparency:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT vbak~vbeln
       INTO lw_data
       FROM vbak
       INNER JOIN vbfa ON vbak~vbeln = vbfa~vbelv
       WHERE vbfa~vbelv IS NULL.
    &amp;lt;you can do your process here&amp;gt;
ENDSELECT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is 100 % the same. Nevertheless it will never retrieve a single record because vbelv is never stored as a NULL value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this can be solved using a subquery&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA : lt_data TYPE table of vbak-vbeln.
SELECT vbeln
       INTO  lt_data   
       FROM vbak
       WHERE NOT EXISTS 
	     ( SELECT * FROM vbfa WHERE vbelv = vbak~vbeln ).
    &amp;lt;you can do your process here&amp;gt;
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To be honest: I did not try the code, never played with subqueries though I should do so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 15:20:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-sql-question/m-p/7575861#M1565846</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-01-26T15:20:41Z</dc:date>
    </item>
  </channel>
</rss>

