Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Delete restrict for ABAP Dictionary database table

Former Member
0 Kudos
1,063

Hi,

I defined two database tables in ABAP dictionary, one with master data, and one with records referencing the master data.

I also defined a foreign key relationship in the second table, so that new entries in the second table are checked against the master data table.

In addition to this behaviour, I also want the Dicitionary to perform a check the other way round. In other words, if I try to delete a record in the master data table, this should not be possible if there are records in the second table referencing this record. Thats how foreign key relationships work in Oracle databases.

Is there a way to force this behaviour for ABAP Dictionary tables, too? Or is it possible to make the table maintenance view perform this check?

Thanks for your help!

Kind regards,

Tobias

7 REPLIES 7
Read only

Former Member
0 Kudos
755

Hi Tobias,

As you defined two tables, with foreign key relation this check is already there, no need of extra check once you are going to delete the entry from master table system automatically check the entry on its dependent table and if it exists then entry will not deleted from master table,

Thanks,

Dharmishta

Read only

0 Kudos
755

Hi Dharmishta,

thanks for your reply.

Unfortunately, I can delete records in the master table which have dependent entries in the second table without an error or a warning.

Did I forget to make any settings in the Dictionary? I definded the foreign key relationship with 1:CN cardinality in the dependent table.

Thanks,

Tobias

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Kudos
755

Hello Tobias,

I can delete records in the master table which have dependent entries in the second table without an error or a warning.

How are you deleting the entries, via SM30?

If yes, you can use the [Event 03: Before Deleting the Display Data|http://help.sap.com/saphelp_nw04s/helpdata/en/91/ca9f14a9d111d1a5690000e82deaaa/content.htm]. In this TMG event you can check if the entry can be deleted at all!

If you're using Open SQL statements to delete the records, i don't think DB layer implicitly checks the dependency. You can always put an explicit check though

Btw, out-of-curiosity, is this a custom or standard table?

BR,

Suhas

Read only

0 Kudos
755

if your master table was entered as check table on the screen where you determine foreign keys and then if everything goes well and you are successfully able to create the foriegn key relation then you should not e able to delete entries from master table.

can you let us know the steps you've used to add teh foreign keys

Read only

0 Kudos
755

can you let us know the steps you've used to add teh foreign keys

I selected the field referencing to the master table in the dependent table and clicked on the foreign key button.

I entered the master table as check table and the and the key fields have been assigned with the referencing fields correctly. The "screen check required" option is marked as default and I added the sematic attributes "non-key-fields" and cardinality 1:CN. Then I confirmed everything and activated the table.

Read only

0 Kudos
755

and how are you deleting the records, is it through a program?

Read only

0 Kudos
755

and how are you deleting the records, is it through a program?

I delete them using the table maintenance I generated (SM30)