‎2005 May 31 12:14 PM
Hi,
I am giving a delete <tablename> statement in a macro, the table name is passed as a parameter. However while compiling it gives me an error saying that it expects a where condition but I dont have an where condition I want to delete all the entries in the table. I dont want to use client specified. this problem occurs only if it is a SAP standard table. There is a statement in INFORMIX like delete from <tablename> where 1=1. Is there any statement like this in ABAP.
Regards
Raghu
‎2005 May 31 12:19 PM
Hi,
try delete from (tabname).
Additionally check out the F1-help on the keyword delete.
regards
Siggi
Message was edited by: Siegfried Szameitat
‎2005 May 31 12:27 PM
Hi,
I tried DELETE (IADR&1). and it did not work, it shows compilation errors
‎2005 May 31 12:30 PM
‎2005 May 31 12:37 PM
This is usually how I delete all records of a database table.
delete from <tablename> client specified
where mandt = sy-mandt.
You could also use the following syntax if your internal table has all the database table records that you want to delete.
delete <db_table> from table <itab>.
Regards,
Rich Heilman
‎2005 May 31 12:42 PM
no, that also did not work, i tried it and then only posted it
‎2005 May 31 12:43 PM
delete from (tabname) will delete the database table.
Give a condition that will always be +ve.
Like if you r deleting from t_mara...
give delete itab where matnr <> space.
Or still better, use refresh itab. clear itab.
Pls reward proper points to the answer that helped u sovle ur problem.
‎2005 May 31 12:53 PM
‎2005 May 31 12:56 PM
‎2005 May 31 1:04 PM
I've just tested the statements which I suggestion above. They both work well. Can you post some of the relevant code. Here is the code that I have tested.
data: itab type table of zdbtab with header line.
select * into corresponding fields of table itab
from zdbtab.
delete zdbtab from table itab.
Regards,
Rich Heilman
‎2005 May 31 1:24 PM
Hi all,
I also have some programs where I have the statment
DELETE FROM (tabname).
It works.
So in this case I think there is an issue with the parameter of the macro. May be you should give it a try to create a subroutine as follows:
form delete_table using p_tabname type c.
delete from (p_tabname).
endform.
I strongly believe that this will work.
regards
Siggi
‎2005 Jun 01 5:50 AM
DEFINE SELECT_ADR_S.
SELECT * INTO CORRESPONDING FIELDS OF TABLE IADR&1
FROM ADR&1S
WHERE TRKORR = H_TRKORR.
DELETE ADR&1S from IADR&1.
DELETE ADR&1S.
*. "CLIENT SPECIFIED
WHERE CLIENT EQ SY-MANDT.
END-OF-DEFINITION.
This is the potion of code i have written. Deletion is from a Database Table
‎2005 Jun 01 5:58 AM
Hi,
Syntax for delete is
<b>DELETE FROM <Databasetable name>.</b>
or
<b>DELETE (dbtabname) FROM TABLE itab.</b>
<i>U have missed <b>Table</b> itab</i>
DELETE ADR&1S from <u><b>Table</b></u> IADR&1.
Also
DELETE <u><b>From</b></u> ADR&1S.
It will work fine.
Also got this info from help docu
<b>DELETE FROM DATABASE dbtab(ar) ... ID key.</b>
Addition:
... CLIENT f
Effect
Deletes the data cluster stored in the table dbtab under the area ar (constant) and the ID key (field or literal) (EXPORT ... TO DATABASE ...).
Example
TABLES INDX.
TYPES: BEGIN OF TAB OCCURS 1,
CONT(30),
END OF TAB.
DATA: FLD(30) TYPE C,
TAB TYPE TABLE OF TAB_TYPE WITH NON-UNIQUE DEFAULT KEY,
WA_INDX TYPE INDX.
...
EXPORT TAB FROM TAB
FLD FROM FLD TO DATABASE INDX(AR)
ID 'TEST'.
You can delete this data cluster with the following statement:
DELETE FROM DATABASE INDX(AR) ID 'TEST'.
Addition 1
... CLIENT f
Effect
Deletes the data cluster in the client specified in the table f (only with client-specific import/export databases).
<b>Example
TABLES INDX.
DELETE FROM DATABASE INDX(AR) CLIENT '001' ID 'TEST'.</b>
Thanks & Regards,
Judith.
Message was edited by: Judith Jessie Selvi
‎2005 Jun 01 6:18 AM
Hi,
I get an error saying that "Delete from dbtab" should be followed by a where condition.
Regards
Raghu
‎2005 Jun 01 6:25 AM
Can you copy paste your code here, we can correct it test it and post it back here.
Regards
Raja
‎2005 Jun 01 6:25 AM
Hi,
It is not like that the syntax is correct.
Kindly check it once more
or u can try as
DELETE from ADR&1S where TRKORR = H_TRKORR.
that is in the select condition.
Thanks & Regrads,
Judith.
‎2005 Jun 01 6:26 AM
Hi,
Instead of the select & delete statement,I suggest you to write the following.
delete from ADR&iS where TRKORR = H_TRKORR.
In your code,you are selecting the record which satisfies TRKORR = H_TRKORR and then deleting the selected lines from the table.Instead of that this piece of code directly deletes the records from the database table.
‎2005 Jun 01 6:47 AM
‎2005 Jun 01 7:13 AM
*----
DEFINE SELECT_ADR_S.
SELECT * INTO CORRESPONDING FIELDS OF TABLE IADR&1
FROM ADR&1S
WHERE TRKORR = H_TRKORR.
DELETE ADR&1S from IADR&1.
DELETE ADR&1S.
DELETE (IADR&1).
*. "CLIENT SPECIFIED
WHERE CLIENT EQ SY-MANDT.
END-OF-DEFINITION.
This is the portion of code
‎2005 Jun 01 7:17 AM
Hi Raghuram,
Have you tried my suggestion?
Instead of the select & delete statement,I suggest you to write the following.
delete from ADR&iS where TRKORR = H_TRKORR.
In your code,you are selecting the record which satisfies TRKORR = H_TRKORR and then deleting the selected lines from the table.Instead of that this piece of code directly deletes the records from the database table.
Reward points for those answers which are useful.
‎2005 Jun 01 7:17 AM
You are using the Delete statement within the
Define ...
End-of-definition.
SO it might not work. Check with that.
‎2005 Jun 01 7:21 AM
following the modified code. i didnot get compilation error.
DEFINE select_adr_s.
select * into corresponding fields of table iadr&1
from adr&1s
where trkorr = h_trkorr.
* DELETE ADR&1S from IADR&1.
delete from adr&1s where trkorr = h_trkorr .
* DELETE (IADR&1).
*. "CLIENT SPECIFIED
* WHERE CLIENT EQ SY-MANDT.
END-OF-DEFINITION.Please note also using
delete from adr&1s .
delete adr&1s .
for the delete process also did not give me compilation error.
I would suggest that if the code is not too large copy/paste the whole program here. particulary the place where you are using this macro.
Regards
Raja
also have a look at the following weblog to learn about how to say thanks to the fellow SDNers who are trying to help you.
/people/mark.finnern/blog/2004/08/10/spread-the-love
‎2005 Jun 01 7:26 AM
Hi,
I also checked with the following:
DEFINE select_adr_s.
*SELECT * INTO CORRESPONDING FIELDS OF TABLE IADR&1
*FROM ADR&1S
*WHERE TRKORR = H_TRKORR.
DELETE ADR&1S from IADR&1.
delete from (&1).
DELETE (IADR&1).
*. "CLIENT SPECIFIED
WHERE CLIENT EQ SY-MANDT.
END-OF-DEFINITION.
select_adr_s 'ZTEST'.
It deleted all entries in the table and it is compilable without any error.
Siggi
‎2005 Jun 01 8:22 AM
Hi Raghu,
I suppose you can try out something like this -
ranges r_mandt for T000-mandt.
delete from <tablename> client specified
where mandt in r_mandt.Here, if r_mandt is initial, all the entries in the table would be deleted.
Regards,
Anand Mandalika.