<?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: Select Statement issue in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607176#M272474</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;Put all your records in a range table and use Exclude(E) option and then write select statement as usual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from &amp;lt;table&amp;gt;&lt;/P&gt;&lt;P&gt;   where fieldname in range table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively you can also use method shown in earlier post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Sep 2006 13:34:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-09-14T13:34:17Z</dc:date>
    <item>
      <title>Select Statement issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607174#M272472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI All,&lt;/P&gt;&lt;P&gt;    I have 10 records in a internal table. I have 20 records in a database table. i want those records from the database table which does not exists in internal table.Which is the better select statement for this situation with performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Hazam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2006 13:31:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607174#M272472</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-14T13:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select Statement issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607175#M272473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Select * from &amp;lt;tabname&amp;gt; into &amp;lt;internal table&amp;gt; for all entries in &amp;lt;itab&amp;gt; where field1 ne itab-field1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prakash.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2006 13:33:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607175#M272473</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-14T13:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Select Statement issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607176#M272474</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;Put all your records in a range table and use Exclude(E) option and then write select statement as usual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from &amp;lt;table&amp;gt;&lt;/P&gt;&lt;P&gt;   where fieldname in range table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively you can also use method shown in earlier post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2006 13:34:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607176#M272474</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-14T13:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select Statement issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607177#M272475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use "FOR All entries" in this case of select statements..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The example code is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from DBTABLE&lt;/P&gt;&lt;P&gt;         into table INTERNALTABLE&lt;/P&gt;&lt;P&gt;         for all entries in ITABWITH10records&lt;/P&gt;&lt;P&gt;         where keyfield &amp;lt;&amp;gt; ITABWITH10records-keyfield.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2006 13:35:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607177#M272475</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-14T13:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select Statement issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607178#M272476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this .......never tried like this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;if not itab1[] is initial.
select * from ztable into table itab2 for all entries in itab1
where fld1 ne itab1-fld1 and
      fld2 ne itab1-fld2.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2006 13:35:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607178#M272476</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-14T13:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select Statement issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607179#M272477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;simplest way is just fetch all the records instead of checking each and every record of internal table with database table records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select f1 f2 f3 &lt;/P&gt;&lt;P&gt;       from mara&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;       into table itab&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;       where &amp;lt;condition&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this will just replace all the existing records of ITAB with the new values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here alternatively you can use &amp;lt;b&amp;gt;RANGES&amp;lt;/b&amp;gt;. but if your primaarey key of that database table is only 1 field,then you can use RANGES. but if your WHERE condition fields also more,then this way of doing with RANGES is time consuming.&lt;/P&gt;&lt;P&gt;For example, if you are fetching data from MARA table,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RANGES R_MATNR FOR MARA-MATNR.&lt;/P&gt;&lt;P&gt;R_MATNR-SIGN = 'E'.&lt;/P&gt;&lt;P&gt;R_MATNR-OPTION = 'EQ'.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1.&lt;/P&gt;&lt;P&gt;  R_MATNR-LOW = ITAB1-MATNR.&lt;/P&gt;&lt;P&gt;  APPEND R_MATNR.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;Now R_MATNR will have all material nos fromn the first internal table.&lt;/P&gt;&lt;P&gt;then send this to select &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM MARA&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;         APPENDING TABLE ITAB1&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;         WHERE MATNR NOT IN R_MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Srikanth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Srikanth Kidambi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Srikanth Kidambi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2006 13:35:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607179#M272477</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-14T13:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select Statement issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607180#M272478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hazam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get all the records into another internal table and delete comparing your already having internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try getting your primary keys in to ranges and use in select statement where not in these ranges. But this is goign to depend on your primary keys and records that you got.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Anu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2006 13:37:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607180#M272478</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-14T13:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Select Statement issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607181#M272479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi hazam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i simulated ur question in my system&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for the best prformance do this.&lt;/P&gt;&lt;P&gt;1. select all the data from the data base table to an internal table. (dont use any where condition)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. sort that internal table by key. (faster procees)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.delete the unwanted data. ( Bcoz by deleting we can save memory space).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rgds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;anver&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if hlped mark points&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2006 13:46:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607181#M272479</guid>
      <dc:creator>anversha_s</dc:creator>
      <dc:date>2006-09-14T13:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Select Statement issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607182#M272480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Case 1:&lt;/P&gt;&lt;P&gt;=======&lt;/P&gt;&lt;P&gt;1. Select all the data from the database in to internal tableand sort according to Primary keys ( Also on secondary keys if any).&lt;/P&gt;&lt;P&gt;2. Delete the rows which are not required&lt;/P&gt;&lt;P&gt;3. But, apart from the primary key, if your filtering depends up on some other keys, I would suggest you to create secondary index in the DB table for that field. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case performance would be very good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Case 2:&lt;/P&gt;&lt;P&gt;=======&lt;/P&gt;&lt;P&gt;1. Use ranges in the select condition provided keys fields are not more than 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Case 3:&lt;/P&gt;&lt;P&gt;=======&lt;/P&gt;&lt;P&gt;Using all entries against the DB table with condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this is suffice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regs,&lt;/P&gt;&lt;P&gt;Venkat Ramanan N&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2006 13:59:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607182#M272480</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-14T13:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Select Statement issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607183#M272481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi hazam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;populate all the 20records into an internal table say itab1.&lt;/P&gt;&lt;P&gt;let the already populated 10 records be in the table itable.&lt;/P&gt;&lt;P&gt;loop at itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itable with key----&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;itab2-field1 = itab1-field1.&lt;/P&gt;&lt;P&gt;itab2-field2 = itab1-field2.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&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;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;sudha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2006 14:17:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-issue/m-p/1607183#M272481</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-14T14:17:12Z</dc:date>
    </item>
  </channel>
</rss>

