Show TOC

 Generic and Constant Foreign KeysLocate this document in the navigation structure


You can use generic foreign keys when you have to do a search in a table using only certain fields of the foreign key. Using generic foreign keys, you can exclude fields from the assignment to the key fields of the check table. The check is only against the remaining key fields. Thus you do not have to check a foreign key against all the key fields of the check table. This is true for example for time-dependent check tables and for check tables whose version number is a component of the key.

You can also assign a constant value to a key field of the check table. In this case, you only have to check against the specified constant. You can use this check if only records of the check table which contain a constant value in this key field are valid.


In the following example you can see an execution of a check where generic and constant foreign keys are used. In the first figure below you can see the relations between the foreign key table FTAB and the check table PTAB. You set Field 2 from the check table as generic and Field 4 for constant with value K.

The corresponding SELECT statement for the screen check has the following form for the foreign key definition in the figure:



This SQL statement is a pseudo code that explains the corresponding functionality. The syntax of this statement is not the same in ABAP.

The values entered in the Input template are the criteria for the searched records in the check table. An entry is valid in check field Field6 if a record of check table PTAB exists containing the input value for Field6 in PTAB-Field1, the input value for Field8 in PTAB-Field3 and constant K in PTAB-Field4.

The values entered on the screen for Field7 and Field9 are meaningless when checking against the check table. An entry with Field6 = 1, Field8 = 3 and Field9 = B is not valid in this case since there is no record with PTAB-Field1 = 1, PTAB-Field3 = 3 and PTAB-Field4 = K in the check table.