10-19-2005 1:17 PM
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.
10-19-2005 1:22 PM
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
10-19-2005 1:25 PM
10-19-2005 1:27 PM
10-19-2005 1:28 PM
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>.
10-19-2005 1:31 PM
You can use
Delete from dbtab where mandt = sy-mandt.
This will work if you have client as part of your table.
Regards,
Raj
10-19-2005 1:33 PM
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
10-19-2005 1:35 PM
hi,
have you delete an internal table or a db table?
for internal table you can use
refresh your_table.
10-19-2005 1:36 PM
10-19-2005 1:45 PM
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.
10-19-2005 1:53 PM
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.
10-19-2005 3:02 PM
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
10-19-2005 3:44 PM
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.