07-31-2009 9:43 AM
Hi,
We have a error message regarding the following code :
Delete FROM TABLE FOR ALL ENTRIES IN lt_TABLE WHERE
TABLE_KEY1 = LT_TABLE_KEY1
Could we use the For All entries with "Select" ?
For information, the error message is "Unable to interpret "FOR". Possible causes: Incorrect spelling or comma error.
Thank you.
07-31-2009 9:54 AM
Hi,
You can not delete from database table like this.
Use a loop on internal table and delete inside comparing values in where clause.
Regds,
Anil
07-31-2009 9:54 AM
Hi monsdn,
we can use for all entries with select statement.
if i_tab is not initial.
select f1 f2
from mara
into table i_tab1
for all entries in i_tab
where f1 = i_tab-f1.
for delete statement,use like....
delete i_tab where f1 not in i_tab1.
or,
delete i_tab where f1 not in so_matnr(select-options).
Hope this can solve your problems.
Regards,
Tutun
07-31-2009 9:54 AM
Hi,
You can not delete from database table like this.
Use a loop on internal table and delete inside comparing values in where clause.
Regds,
Anil
07-31-2009 10:04 AM
Thank you Anil,
Could you give me the syntaxe please basing on my example, because I m beginner on ABAP program.
Delete FROM TABLE FOR ALL ENTRIES IN lt_TABLE WHERE
TABLE_KEY1 = LT_TABLE_KEY1
Thx.
Edited by: monsdn on Jul 31, 2009 11:04 AM
07-31-2009 10:09 AM
HI,
In order to delete data base table entries the structure of db table and ur table should be same.
Get all the records in the internal table and then use this command.
delete <database table> from table itab.
if sy-subrc eq 0.
commit work.
endif.
Regards,
Nagaraj
07-31-2009 10:12 AM
Hi,
You can try this
loop at lt_table.
Delete TABLE where TABLE-KEY1 = LT_TABLE-KEY1.
endloop.
Regards,
Vik
07-31-2009 10:14 AM
Delete TABLE lt_TABLE WHERE
TABLE_KEY1 = LT_TABLE_KEY1
write delete and press f1 and see the syntax
Thanks
Bala Duvvuri
07-31-2009 10:20 AM
Hi,
Check the below syntax, if you want to delete from database
DELETE FROM sflight
WHERE carrid = p_carrid AND
fldate = sy-datum AND
seatsocc = 0.
Just a suggestion. May be from next time you can use F1 help for syntax:
1. Place the cursor on the delete keword in your program and press F1 - You willl get all the possible syntax for delete statement
2. Else open the transaction ABAPDOCU, Click Keyword Help, Enter the required keyword(delete in this case) and press cont.. You will get the syntax.
Hope thsi will help you.
Regards,
Swarna Munukoti.
07-31-2009 10:28 AM
Hi,
tables : ztarget.
data : begin of itab occurs 0.
include structure ztarget.
data : end of itab.
select * into table itab from ztarget.
loop at itab.
delete from ztarget where kunnr = itab-kunnr.
endloop.
Regds,
Anil
Edited by: Anil Katoch on Jul 31, 2009 11:29 AM
08-15-2009 8:23 PM
08-15-2009 10:10 PM
please flag "solved" to the people who gave the correct solution, so that people who will have the same question later, will get directly the answer.
08-19-2009 10:20 AM
hey, don't mark my post HAS SOLVED your question, or I should indicate to moderators that you ABUSE !
07-31-2009 9:55 AM
Hello,
For such issues you should check syntax help provided by SAP.
Thanks,
Augustin,
07-31-2009 10:16 AM
Hi,
here is the piece of code.... try to do in the following way..
put the records u want to delete in an internal table and then delete the datbase table from that internal table..
SELECT carrid connid fldate
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE sflight_key_tab
WHERE carrid = p_carrid AND
fldate = sy-datum AND
seatsocc = 0.
DELETE sflight FROM TABLE sflight_key_tab.
Thanks
Ashu
07-31-2009 10:18 AM
The correct syntax is
delete from it_TABLE WHERE TABLE_KEY1 = LT_TABLE_KEY1.
and
select matnr from mseg into table i_table1
for all entries in it_TABLE
where mblnr = it_TABLE-mblnr.
05-19-2014 10:04 PM
I see where this has been answered but here is another way to do this.
To delete all entries in an internal table:
REFRESH it_table.