abapopensqlsap-data-dictionary

How to make automatic cascading deletions for DDIC-tables?


Is it possible to trigger a cascading delete for a table with a foreign key relation to another table? DDIC allows defining foreign key relations, which could (in theory) be used to implement cascading delete.


Solution

  • There are no database triggers in SAP. So you can't react to an operation on a database immediately. However you could create a job that runs from time to time to check the foreign keys.

    I wouldn't recommand doing this with standard tables, though. You never know what kind of operations are allowed in the SAP standard, where there might be a foreign key relation without the key beeing defined in the other table. SAP is just weird sometimes.

    If you wanna do it for your custom developments and expand on it dynamically, sure. You can check the DB DD08L for foreign key relations. However the table also holds all structures which have checktables, so you'd have to filter those. The DB DD02L can help with that (field TABCLASS defines the kind of object).