2007 Jul 20 10:47 AM
Hi,
can some one please tell me the syntax for the delete statement?
I need to delete a Line from an Internal table with condition similar to :
DELETE TABLE itab WITH TABLE KEY k1 = v1 ... kn = vn.
But I am gettin a syntax error: I have to mention all the filedsa defined in the int table itab.
kindly point out the mistake or an alternate method.
Thanks.
2007 Jul 20 10:50 AM
Use this,
DELETE itab WHERE k1 = v1 ... kn = vn
Reward points.
Regards,
Sairam
2007 Jul 20 10:49 AM
Hi,
DELETE TABLE itab: FROM line,
WITH TABLE KEY k1=v1.
Regards,
Sridevi
<i><b>Assign points, if useful</b></i>
2007 Jul 20 10:49 AM
hi,
remove table i.e
delete table itab where k1 = v1...
check this one for syntax regarding delete
http://www.sts.tuharburg.de/teaching/sap_r3/ABAP4/delete.htm
2007 Jul 20 10:50 AM
Use this,
DELETE itab WHERE k1 = v1 ... kn = vn
Reward points.
Regards,
Sairam
2007 Jul 20 10:50 AM
use DELETE itab where k1 = v1 .... kn = vn.
or pass the index
DELETE itab index idx.
Regards
Prax
Message was edited by:
Prax
2007 Jul 20 10:50 AM
hi
check if this helps
DELETE itab - table_key
Syntax
... { FROM wa }
| { WITH TABLE KEY {comp_name1|(name1)} = dobj1
{comp_name2|(name2)} = dobj2
... } ... .
Effect
You can specify the values of the search key either implicitly after FROM in a work area wa or by explicitly listing the components of the table key after TABLE KEY.
Alternatives:
1. ... FROM wa ...
2. ... WITH TABLE KEY ...
Alternative 1
... FROM wa ...
Effect
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.
Note
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.
Example
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.
PARAMETERS p_carrid TYPE scarr-carrid.
DATA: scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid,
scarr_wa LIKE LINE OF scarr_tab.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
IF sy-subrc = 0.
scarr_wa-carrid = p_carrid.
DELETE TABLE scarr_tab FROM scarr_wa.
ENDIF.
Alternative 2
... WITH TABLE KEY ...
Effect
Each component of the table key must be specified either directly as comp_name1 comp_name2 ... or as a character-type data object in parentheses name1 name2 ..., which contains the name of the component in uppercase when the statement is executed. If name contains only blank characters, this component entry is ignored when the statement is executed. Every component must be assigned a data object dobj1 dobj2 ... that is compatible with or convertible to the data type of the component. The statement deletes the first internal table row whose values in the columns of the table key match those in the assigned data objects dobj1 dobj2 .... If necessary, the content of dobj1 dobj2 ... is converted to the data type of the component before the comparison.
The individual table kinds are accessed as follows:
Standard tables are searched on a linear basis
Sorted tables are searched on a binary basis
Hashed tables are searched using the hash algorithm
Note
If a table has a non-structured row type and the entire table row is defined as the table key, you can specify the pseudo component table_line as the component.
Example
By explicitly specifying the table key, the table row is deleted that has the same value as p_carrid in the key field carrid.
PARAMETERS p_carrid TYPE scarr-carrid.
DATA scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
DELETE TABLE scarr_tab WITH TABLE KEY carrid = p_carrid.
regards
dinesh
2007 Jul 20 10:52 AM
DELETE itab WITH TABLE KEY k1 = v1 ... kn = vn.
Regards,
Pavan
2007 Jul 20 10:54 AM
Hi,
Use the following statment.
suppose you have internal table say itab. then put query like this
<b>delete itab where table filed = 'abc'.</b>
you have to mention the internal table field in table field and also have to put the condtion to delete the record.
Rewards if useful.
Regards,
Kinjal