‎2005 Nov 20 7:48 PM
Hi friends,
i wanted to know the concept of foregin table & chk table. And also the procedure & steps in creating them.
So kindly please helpme on that.
ThanksIn Advance
Rinky
‎2005 Nov 20 8:39 PM
Hi
I suppose you're speaking about foreign key (not table), aren't you?
The check table is the table contains all values can be contained in another table.
For example you want to create a new table where a field is LIFNR (vendor), now you should allow only vendor defined in SAP can be inserted in your table.
You can do it in dictionary inserting a check table (in this case LFA1) for field LIFNR of your table.
Now if you create a dialog program to insert a new record in your table and you use ZTABLE-LIFNR as input field, if user tried to insert a vendor there isn't in LFA1, the system automatically triggers an error message.
If you don't use the check table, you should do this control by yourself:
SELECT SINGLE * FROM LFA1 WHERE LIFNR = ZTABLE-LIFNR.
IF SY-SUBRC <> 0. ERROR. ENDIF.
Anyway nobody can prevent an error enter by command INSERT or MODIFY.
IF LFA1-LIFNR = 'AAAAAAAAAA' isn't in the table LFA1, you could write:
ZTABLE-LIFNR = 'AAAAAAAAAA'.
INSERT ZTABLE.
But this is an your error during the development of your program.
The foreign key is the key links the field with its check table.
In this case it's ZTABLE-LIFNR = LFA1-LIFNR.
All dictionary table could be a check table, it only depends on what you want to check.
The check tables usually are the master data table, because they are the tables where the data are defined.
While creating a new table if you want to check a field by a (check) table, you push KEY icon, the system'll propose you the value table as check table (you can accept it or use another table) and then it'll propose the link between checked field (of your table) and checking field (of check table).
The value table is the table where the possible values are, it's defined in DOMAIN.
For example the domain LIFNR has LFA1 as value table.
So if you create a table with field LIFNR with data element LIFNR, and so with domain LIFNR, when you'll create a foreign key for this field, the system'll propose you LFA1 as check table.
Max
‎2005 Nov 20 8:39 PM
Hi
I suppose you're speaking about foreign key (not table), aren't you?
The check table is the table contains all values can be contained in another table.
For example you want to create a new table where a field is LIFNR (vendor), now you should allow only vendor defined in SAP can be inserted in your table.
You can do it in dictionary inserting a check table (in this case LFA1) for field LIFNR of your table.
Now if you create a dialog program to insert a new record in your table and you use ZTABLE-LIFNR as input field, if user tried to insert a vendor there isn't in LFA1, the system automatically triggers an error message.
If you don't use the check table, you should do this control by yourself:
SELECT SINGLE * FROM LFA1 WHERE LIFNR = ZTABLE-LIFNR.
IF SY-SUBRC <> 0. ERROR. ENDIF.
Anyway nobody can prevent an error enter by command INSERT or MODIFY.
IF LFA1-LIFNR = 'AAAAAAAAAA' isn't in the table LFA1, you could write:
ZTABLE-LIFNR = 'AAAAAAAAAA'.
INSERT ZTABLE.
But this is an your error during the development of your program.
The foreign key is the key links the field with its check table.
In this case it's ZTABLE-LIFNR = LFA1-LIFNR.
All dictionary table could be a check table, it only depends on what you want to check.
The check tables usually are the master data table, because they are the tables where the data are defined.
While creating a new table if you want to check a field by a (check) table, you push KEY icon, the system'll propose you the value table as check table (you can accept it or use another table) and then it'll propose the link between checked field (of your table) and checking field (of check table).
The value table is the table where the possible values are, it's defined in DOMAIN.
For example the domain LIFNR has LFA1 as value table.
So if you create a table with field LIFNR with data element LIFNR, and so with domain LIFNR, when you'll create a foreign key for this field, the system'll propose you LFA1 as check table.
Max
‎2005 Nov 20 11:08 PM
Foreign Keys
You can define the relationships between tables in the ABAP Dictionary by creating foreign keys.
Using foreign keys, you can easily create value checks for input fields. Foreign keys can also be used to link several tables in a view or a lock object.
Check Table
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.
The check table is used to check whether the input values are valid and for the input help (F4 help).
For procedure to create see below link
http://help.sap.com/saphelp_46c/helpdata/en/b2/fbb85cc64611d295dd00a0c929b3c3/frameset.htm
For more help on this see below link
http://help.sap.com/saphelp_46c/helpdata/en/34/8e748b6df74873e10000009b38f9b8/frameset.htm