The relational data model contains not only tables, but also relationships between tables. These relationships are defined in the ABAP/4 Dictionary by foreign keys.
If you go to SE11, type in the name of your table and click on “Change”. Click on the name of the field that you want to use a check table for. Now click on the foreign key button (the button that has a key and an arrow).
You can enter values in the foreign key table if there exist a record in check table. Data element − Every Search Help parameter or field by default is assigned a data element that was assigned to it in the source of data (Table or View). This data element name appears in display mode.
An important function of foreign keys is to support data integrity in the relational data model. Foreign key fields may assume only those values allowed by the check table, in other words, values occurring in the primary key of the check table. The ABAP Dictionary allows you to define relationships between tables using foreign keys.
For example if you try to create a record in employee table with Department_ID as ’04’, it will throw an error. A primary key is a field or group of fields that uniquely identify a record in a table.
This brings up a window for the foreign key/check table information. Enter a short text description and the name of the check table, then click on the “Generate proposal” button. Make sure that the “check required” box is checked, select a foreign key field type and cardinality, and then click on the copy button.
Using the function module ‘F4IF_INT_TABLE_VALUE_REQUEST’
If suppose a foreign key links two tables T1 and T2 by assigning fields of table T1 to the primary key fields of table T2. The system proposes the value table as check table when you try to define a foreign key for the field or component. This will not allow entering a Department_ID in the employee table that is not there in the department table.
For this purpose, Foreign key fields assigned to the primary key fields of T2 are included in T1. Table T1, which is the one being checked, is called a foreign key table, and table T2 is called a check table. The terms dependent (foreign key) table and referenced (check) table are also used. If you try to define a foreign key for a field that points to this domain, the value table of the domain is proposed as the check table for the foreign key.
Value table is maintained at the data element level and check table at the dictionary level. The Check Table is the dependent table to which the relationship is defined using foreign keys. A value table only becomes a check table when a foreign key is defined. If you refer to a domain with a value table in a field, but no foreign key was defined at field level, there is no check.
A dependent table is called a foreign key table, and the referenced table is called the check table. Each key field of the check table corresponds to a field in the foreign key table. One of the foreign key fields is designated as the check field for checking the validity of values. The key fields of the check table can serve as input help for the check field.
- The relational data model contains not only tables, but also relationships between tables.
- These relationships are defined in the ABAP/4 Dictionary by foreign keys.
- An important function of foreign keys is to support data integrity in the relational data model.
Creating a Table of Values from a Linear Equation
There is a limit for fields in primary key by the database system. The limit is 16 fields, or 15 if you have to use also the CLIENT (client-specific tables). The system proposes the value table as check table when you try to define a foreign key for this field. When we create a FK relation for a Field, whose domain has been assigned to value table, the system will propose the Value Table as Check table. Value Table is the table attached to a field at the domain level, where the entry to the field can be only from the value table.
Referring to the previous example if you tried to define a check table for the matnr field SAP would propose MARA as the check table. Check table is defined against a field in SE11 if you want the values in that field to be checked against a list of valid values. For e.g. if you are using the field matnr in a table you could define MARA as the check table.
We have seen that it is best to use a function table to describe a function when there are a finite number of inputs for that function. You should now be very comfortable determining when and how to use a function table to describe a function. Also while defining a check table SAP proposes the value table as check table by default.
The check table is the table whose key fields are checked, during maintaining the foreign key relationship. 2)The check table defines the foreign keys and is part of the table definition.
The value table is part of the domain definition. Department_ID becomes the foreign key of employee table and Department table becomes the check table.
What is a value table?
Check Table is for Field level Validation whereas Value table is for Domain Level Validations. Value Table proposes table for check table. The Check Table is the table used by system to check if a data exist or not exist.
Table T1 is called the foreign key table (dependent table) and table T2 is the check table (referenced table). The pair of fields for the two tables must have the same data type and length. One field of the foreign key table therefore corresponds to each key field of the check table. This field is called the foreign key field.A foreign key permits you to assign data records in the foreign key table and check table. One record of the foreign key table uniquely identifies one record of the check table using the entries in the foreign key fields.
difference between check table and valuetable
Primary key fields cannot be NULL and cannot contain duplicate values. The check table is used to check whether the input values are valid and for the input help (F4 help). A function is a rule that assigns a set of inputs to a set of outputs in such a way that each input has a unique output. A function table in math is a table that describes a function by displaying inputs and corresponding outputs in tabular form. Each function table has a rule that describes the relationship between the inputs and the outputs.
SAP ABAP – Foreign Key Relationship Using Check Table
Table T1 is called the foreign key table (dependent table) and table T2 the check table (referenced table). A foreign key links two tables T1 and T2 by assigning fields of table T1 to the primary key fields of table T2. Table T2 is then known as the check table of the foreign key.
Table whose key fields are used to check the foreign key fields (see Foreign Keys). Only entries that are contained in the key fields of the check table can be contained in the foreign key fields. Check Table is the dependent table to which the relationship is defined using the foreign keys. The contents of the check table field are shown in the input help for the referenced field.