Application Development 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: 

Deletion in one shot.

Former Member
0 Kudos

Hi Guys,

i hava requirement after a condtion check ...if it becomes true ..i have to delete all the rows from that table.

can any body suggest me the statement which do this..

i got syntax from documentation like this.

To DELETE all the lines..

where condition must use a itab which is empty..

then u r able to delete all the lines in one shot..

But i need a simple soltuion.

any body help me plz.

i appreciate ur help in advance.

12 REPLIES 12

Former Member
0 Kudos

do you want to delete from an internal table or a DB table...

for internal table....u can use clear itab[] or refresh itab once your condition is true.

check <cond>

refresh itab.

for DB table...u can use <b>delete from dbtab</b>

check <cond>

delete from itab.

rgds,

PJ

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

delete itab.

Former Member
0 Kudos

Refresh itab

Former Member
0 Kudos

i want to delete from data base table only.

i dont have any itab for this data to use <b>FROM</b> clause

Delete from dbtab ...deletes only one record

see the documentaion:

<b>These are SAP-specific short forms used to delete one line of a database table</b>.

0 Kudos

You can use

Delete from dbtab where mandt = sy-mandt.

This will work if you have client as part of your table.

Regards,

Raj

0 Kudos

did u try delete dbtab.

when u specify delete dbtab without a where condition...all rows are deleted..

rgds,

PJ

Message was edited by: Priyank Jain

Former Member
0 Kudos

hi,

have you delete an internal table or a db table?

for internal table you can use

refresh your_table.

Former Member
0 Kudos

I think, you have already asked this question.

Svetlin

Former Member
0 Kudos

Thanks to all of u.

it seems to be where clause mandatory to delete all lines following is the extract from documentation.

Dear Rajendra...

i hope u have given right answer.

let me check if it works.

Thanks

Note

To delete all the lines in a table, you must specify a WHERE condition that is true for all lines. You can achieve this with

... WHERE f IN itab

If the internal table itab is empty, such a condition would select all lines.

0 Kudos

strange....

read this...

DELETE dbtab - cond

Syntax

... WHERE sql_cond.

Effect

The WHERE addition uses a logical expression sql_cond to specify which rows in the database table are deleted. The same applies to the logical expression sql_cond as for the WHERE condition of the SELECT statement. If there is no row in the database that satisfies the WHERE condition, no row is deleted and sy-subrc is set to 4. <b>If no WHERE condition is specified, all rows are deleted.</b>

Note

As of Release 6.10, specifying the WHERE condition is optional. Prior to Release 6.10, you had to specify the WHERE condition in this variant of the DELETE statement and you could not use dynamic logical expressions.

Former Member
0 Kudos

Hi Priyannk,

Thanks for ur reply.

I applied Rajendra logic , it is working but One thing if we include mandt in Where clause, we should mention CLIENT SPECIFIED. it is mandatory.

Thanks rajendra..i rewarded u for ur helpful answer.

6.10 version means what?

I am using 4.6c version of SAP

clarify me 6.10 means...

Thanks in advance...

RAJA

0 Kudos

6.10 is the BASIS Release .

46C is older release as compared to 6.10.

( SAP has various releases LIKE 40b-> 45b -> 46b.. )

You are correct i.e. in 46C where condition is mandatory if you want to delete all the data .

Priyank is also correct in saying that as of release 6.10 where clause is not manadatory and if not specified will delete all the data in table . This will not work for you as you are on 46C .

So all the confusion due to version ( Basis Release ).

Cheers.