01-10-2006 1:52 PM
Hi.
I want to know if we can use a SELECT-OPTION in a query to delete a TABLE ?
For example :
SELECT-OPTIONS:
so_tname FOR DD02L-TABNAME.
I know in a select I can do something like that :
SELECT TABNAME
FROM DD02L
INTO TABLE INT_TAB
WHERE TABNAME IN so_tname
Can we use something similar in a DELETE query ? Because for the moment i'm only able to do that with a parameter on 1 table.
DELETE
FROM (p_tab)
WHERE ....
Thanks
01-10-2006 1:53 PM
Hi
Yes you can:
DELETE FROM <TABLE> WHERE <COND IN SELEC-OPTION>
Max
01-10-2006 1:53 PM
Hi helder,
1. Yes ofcourse.
delete from dbtab
where fieldname in seloption.
*----
VERY IMPORTANT.
2. MAKE SURE THERE IS SOME VALUE
IN SELECT-OPTION
IF IT IS BLANK,
ALL RECORDS IN THE TABLE WILL BE DELETED !!!!
regards,
amit m.
Message was edited by: Amit Mittal
01-10-2006 1:53 PM
Hi
Yes you can:
DELETE FROM <TABLE> WHERE <COND IN SELEC-OPTION>
Max
01-10-2006 2:02 PM
In fact what i need is to clear all the records in the table of the select-options.
If i have : ztest1, ztest2, ztest3 in the select options, i want to clear these 3 tables.
01-10-2006 2:06 PM
Hi again,
1. i tried at my end.
it works pefectly fine.
2. sample code (just copy paste)
REPORT zam_temp07 .
DATA : tname LIKE dd02l-tabname.
SELECT-OPTIONS : tn FOR tname.
LOOP AT tn.
DELETE FROM (tn-low).
ENDLOOP.
regards,
amit m.
01-10-2006 2:24 PM
Hi
If you want to delete all hits in your table you can use DELETE FROM without where conditions, it works from rel. 4.7, I don't remember for other release.
SELECT-OPTIONS: SO_TAB FOR DD02L-TABNAME.
DATA TAB_TABLE LIKE STANDARD TABLE OF DD02L WITH HEADER LINE.
Make sure to delete only records of existing tables
SELECT * FROM DD02L INTO TABLE TAB_TABLE
WHERE TABNAME IN SO_TAB
AND AS4LOCAL = 'A'.
LOOP AT TAB_TABLE.
DELETA FROM (TAB_TABLE-TAB_NAME).
ENDLOOP.
Remember this code is very dangerous, because you could delete the data of whichever SAP table.
Max
Message was edited by: max bianchi
01-10-2006 2:39 PM
Hi Helder,
Just say,
SELECT-OPTIONS s_matnr FOR mara-matnr.
REFRESH s_matnr.
CLEAR s_matnr.
Remember even if it is a select option, it is a internal table.
Regards,
Srikanth