Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

delete itab

Former Member
0 Likes
973

hi all,

Can I write like this :

delete itab where charg not in s_charg.

where

8 REPLIES 8
Read only

Former Member
0 Likes
948

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

Read only

GauthamV
Active Contributor
0 Likes
948

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.

Read only

Former Member
0 Likes
948

can you not try yourself. and see if we can write in this fashion or not?

Amit.

Read only

former_member200872
Active Participant
0 Likes
948

Hi,

Syntactically it is correct.

Read only

vinod_vemuru2
Active Contributor
0 Likes
948

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.

Read only

Former Member
0 Likes
948

Hi,

Yes you can write. its correct statement.

Regards,

Sathish Reddy.

Read only

Former Member
0 Likes
948

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.

Read only

Former Member
0 Likes
948

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