2010 Jul 22 9:28 AM
Hello,
I have a primary table and seconday table with Foreign Key. when I delete the record from primary table, i want to delete all recrods from secondary table. Is there command in ABAP like cascade on delete?
Thanks,
Ahmed
2010 Jul 22 9:32 AM
Hi!
You have to clean up the records from the second table for yourself.
DELETE FROM second_table WHERE foreign_key = first_table-key.
Regards
Tamá
2010 Jul 22 9:53 AM
Thanks for the reply.
But I have multiple records to be deleted from first table. So I have to loop to delete records from secondary table. Can I do without loop.
Regards,
Ahmed
2010 Jul 22 10:00 AM
Of course you can.
1. You surely have an internal table, with the entries to be deleted. This table must have the primary keys of your DDIC second_table.
Then use the following code :
IF NOT itab[] IS INITIAL. "don't start the deletion using an empty table
DELETE second_table FROM TABLE itab.
ENDIF.
2. Or you can use the DELETE within a loop.
For more details on the DELETE command, simply press F1, on it, within the ABAP editor.
Regards
Tamá