‎2008 Aug 20 12:03 PM
hi all,
Can I write like this :
delete itab where charg not in s_charg.
where
‎2008 Aug 20 12:07 PM
you could have simply put the statement in a report and tried to activate it. it would have given you the answer whether you can write this or not.
However, the answer is YES you can write a statement like this...
the table specified after IN should have the structure of a seltab with sign, option, low and high
‎2008 Aug 20 12:07 PM
hi,
syntax for delete :
Deleting from a Database Table
- DELETE FROM dbtab. or
DELETE FROM (dbtabname).
- DELETE dbtab FROM wa. or
DELETE (dbtabname) FROM wa.
- DELETE dbtab FROM TABLE itab. or
DELETE (dbtabname) FROM TABLE itab.
- DELETE dbtab. or
DELETE *dbtab.
- DELETE dbtab VERSION vers. or
DELETE *dbtab VERSION vers.
Delete from an internal table
- DELETE itab.
- DELETE TABLE itab WITH TABLE KEY k1 = v1 ... kn = vn.
- DELETE TABLE itab [FROM wa].
- DELETE itab INDEX idx.
- DELETE itab FROM idx1 TO idx2.
- DELETE itab WHERE logexp.
- DELETE ADJACENT DUPLICATES FROM itab.
‎2008 Aug 20 12:09 PM
can you not try yourself. and see if we can write in this fashion or not?
Amit.
‎2008 Aug 20 12:09 PM
‎2008 Aug 20 12:09 PM
Hi Uday,
No. We can't have IN operator with delete where clause.
Why can't u fileter the data while selecting itself.
Thanks,
Vinod.
‎2008 Aug 20 12:09 PM
Hi,
Yes you can write. its correct statement.
Regards,
Sathish Reddy.
‎2008 Aug 20 12:11 PM
yes..y can do this..
Pl. check this sample code:
REPORT Z_TEST_JG.
tables: mseg.
data: itab type standard table of mseg.
select-options: s_charg for mseg-charg.
select * from mseg into table itab
up to 100 rows.
check sy-subrc = 0.
delete itab where charg not in s_charg.
‎2008 Aug 20 12:20 PM
ya it right..
u can write it but in loop-endloop.
Loop at itab.
delete itab where charg not in s_charg.
Endloop.
Edited by: Sachin Gupta on Aug 20, 2008 1:22 PM