<?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: Problem with delete internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525593#M1069847</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;DELETE t_tab1 WHERE &amp;lt;fieldname&amp;gt; NE &amp;lt;values&amp;gt; " Values that you don't want to delete
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this snippet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA :
   BEGIN OF fs_tab,
     a TYPE i,
     b TYPE i,
   END OF fs_tab.

DATA :
   t_tab1 LIKE
 STANDARD TABLE
       OF fs_tab,

   t_tab2 LIKE
 STANDARD TABLE
       OF fs_tab.


DO 10 TIMES.

  fs_tab-a  = -1 * sy-index.
  fs_tab-b  = fs_tab-a * sy-index.

  APPEND fs_tab TO t_tab1.

ENDDO.

DELETE t_tab1  WHERE a NE -2.

LOOP AT t_tab1 INTO fs_tab.

  WRITE :
    / fs_tab-a , fs_tab-b.

ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above snippet all teh values in the internal table are deleted except the entry whose A  field value is '-2'.&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;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Sep 2008 05:22:23 GMT</pubDate>
    <dc:creator>bpawanchand</dc:creator>
    <dc:date>2008-09-30T05:22:23Z</dc:date>
    <item>
      <title>Problem with delete internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525590#M1069844</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 am working on upgrade project from 4.6 to Ecc6&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing a problem with delete internal table statement in ECC 6&lt;/P&gt;&lt;P&gt;The statement is going to dump - " SQL Error in data base when accessing the table"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The statement is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Delete it_table where not ( fld1 in s_fld1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 05:12:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525590#M1069844</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-30T05:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with delete internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525591#M1069845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Internal table with header line is obsolete in 6.0. You need to use work area of table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Delete it_table from wa_itab where not ( fld1 in s_fld1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aparna Gaikwad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 05:16:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525591#M1069845</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-30T05:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with delete internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525592#M1069846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The statement is&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Delete it_table where not ( fld1 in s_fld1 and flds in s_fld2)
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is not causing problem in 4.6&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me how can I use work area and solve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 05:19:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525592#M1069846</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-30T05:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with delete internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525593#M1069847</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;DELETE t_tab1 WHERE &amp;lt;fieldname&amp;gt; NE &amp;lt;values&amp;gt; " Values that you don't want to delete
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this snippet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA :
   BEGIN OF fs_tab,
     a TYPE i,
     b TYPE i,
   END OF fs_tab.

DATA :
   t_tab1 LIKE
 STANDARD TABLE
       OF fs_tab,

   t_tab2 LIKE
 STANDARD TABLE
       OF fs_tab.


DO 10 TIMES.

  fs_tab-a  = -1 * sy-index.
  fs_tab-b  = fs_tab-a * sy-index.

  APPEND fs_tab TO t_tab1.

ENDDO.

DELETE t_tab1  WHERE a NE -2.

LOOP AT t_tab1 INTO fs_tab.

  WRITE :
    / fs_tab-a , fs_tab-b.

ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above snippet all teh values in the internal table are deleted except the entry whose A  field value is '-2'.&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;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 05:22:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525593#M1069847</guid>
      <dc:creator>bpawanchand</dc:creator>
      <dc:date>2008-09-30T05:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with delete internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525594#M1069848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lokesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: it_table  TYPE STANDARD TABLE OF x_table, "-&amp;gt;&amp;gt; x_table is ur structure&lt;/P&gt;&lt;P&gt;          wa_table TYPE x_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Delete it_table from wa_table where not ( fld1 in s_fld1 and flds in s_fld2)&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;Aparna Gaikwad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 05:23:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525594#M1069848</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-30T05:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with delete internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525595#M1069849</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;&lt;/P&gt;&lt;P&gt;Please see below example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternative 1 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... FROM wa ... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;The work area wa must be a data object that is compatible with the row type of the internal table. The statement deletes the first internal table row whose values in the columns of the table key match those of the corresponding components of wa. If the key fields in wa are empty, no entry is deleted. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note &lt;/P&gt;&lt;P&gt;Outside of classes, you can omit the FROM wa addition if the internal table has an identically named header line itab. The statement then implicitly uses the header line as the work area. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;A work area scarr_wa is used to delete the table row that has the same value as p_carrid in the key field carrid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS p_carrid TYPE scarr-carrid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: scarr_tab TYPE SORTED TABLE OF scarr &lt;/P&gt;&lt;P&gt;                WITH UNIQUE KEY carrid, &lt;/P&gt;&lt;P&gt;      scarr_wa  LIKE LINE OF scarr_tab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * &lt;/P&gt;&lt;P&gt;       FROM scarr &lt;/P&gt;&lt;P&gt;       INTO TABLE scarr_tab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0. &lt;/P&gt;&lt;P&gt;  scarr_wa-carrid = p_carrid. &lt;/P&gt;&lt;P&gt;  DELETE TABLE scarr_tab FROM scarr_wa. &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Jana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 05:26:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525595#M1069849</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-30T05:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with delete internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525596#M1069850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ Aparna&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do I need to loop the internal table to work area?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or just the statement you  provided will delete line matching the condition&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 05:27:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525596#M1069850</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-30T05:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with delete internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525597#M1069851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just checked in 6.0. Your statement should not give error. &lt;/P&gt;&lt;P&gt;To avoid this error you can do-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_table into wa_table.&lt;/P&gt;&lt;P&gt;if fld1 in s_fld1 and flds in s_fld2.&lt;/P&gt;&lt;P&gt;DELETE TABLE it_table FROM wa_table. &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;Regards,&lt;/P&gt;&lt;P&gt;Aparna Gaikwad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 05:42:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-delete-internal-table/m-p/4525597#M1069851</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-30T05:42:05Z</dc:date>
    </item>
  </channel>
</rss>

