‎2016 Sep 14 3:56 PM
Dear Experts,
I have created foreign key relationship already using foreign key button then if i try to create an entry in my foreign key table with field 'food' that is not there in the check table. It is acepting the entries which is not having in my check table entries.I need the error message like this 'Entry does not exist in check table - Check your entry'.
I tried not working. Please explain me clearly. How to do this.
Thanks and regards
Samir
‎2016 Sep 14 4:04 PM
are you attempting to insert the entry using a screen/dialog or purely using SQL in ABAP program?
‎2016 Sep 14 4:18 PM
You need to check 2 things.
1. Is the new entry created using a program or thru the screen just as specified on the previous reply.
2. You need to check the cardinality relationship between your check table and FK table.
Thanks,
Vikram.M
‎2016 Sep 14 5:07 PM
The cardinality field of the foreign key is just for information (as said in the field help).
‎2016 Sep 14 6:09 PM
Sandra,
I have not tried this yet, but if the cardinality is defined as N:M and N has a value of 'C', then doesn't the system allow to create entries in FK table even if the check table does not have an entry?
Thanks,
Vikram.M
‎2016 Sep 14 6:39 PM
Hi
You should consider every table exists in two different level:
- Dictionary
- Database
The foreign key is an attribute at dictionary level, as Sandra Rossi has already explained, it can be used to have an automatic validation in the SAP screen (selection-screen or dynpro): in this case the system will do the validation for you automatically
But the sql commands (like INSERT) don't use it, no validation will be done except uniqueness of the record
‎2016 Sep 14 8:20 PM
Sandra/Max,
Thanks. I thought that the cardinality will impact the FK. I just ran a test and it does not affect the same. The error message was raised ir respective of the cardinality.
Vikram.M
‎2016 Sep 14 4:31 PM
Hi
You need you validate the data by yourself before inserting them
The foreign key doesn't work at database level, so the INSERT statament will insert a record though the forign key is not respected.
Max
‎2016 Sep 14 5:06 PM
Or, if it's about a field in a dynpro, the validation is automatic if the dynpro field name is tablename-fieldname and the checkbox "field attached to the DDIC" is ticked (and of course, the foreign key must have checkbox "error if value doesn't exist" ticked).