Get Example source ABAP code based on a different SAP table
• WITH FOREIGN KEY ABAP_DDIC_DEFINE_TABLE • WITH FOREIGN KEY ABAP_DDIC_DEFINE_STRUC
ABAP_DDIC_DDL - DEFINE TABLE>, foreign_key>
ABAP_SYNTAX ... WITH FOREIGN KEY $[[n,m]$] check_table WHERE check_field1 = dbtab.field1 $[AND check_field2 = dbtab.field2 ...$] ...>
What does it do? Assigns a check table> to a table field> whose data type is defined by a data element in the definition of a DDIC database table using the Dictionary DDL> statement DEFINE TABLE>>. check_table> must be an existing DDIC database table. This statement turns check_table> into a check table and turns the current DDIC database table into a foreign key table>. The current table field is turned into a foreign key field> of the foreign key> of the current table.
Fields of the check table must be assigned to the foreign key fields of the foreign key table after WHERE>.
[n,m]> can be used to define the cardinality> of the foreign key >.
The possible values for n> are 1> for 1> and [0..1]> for C>.
The possible values for m> are 1> for 1>, [0..1]> for C>, [1..*]> for N>, and [0..*]> for <(>CN<)>>. Further properties of the foreign key can be specified using foreign_key_annos>>.
Latest notes: The addition WITH FOREIGN KEY> can be used, with the same meaning, in the definition of a structure using DEFINE STRUCTURE>>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Dictionary DDL for specifying the check table SCARR> of the foreign key field CARRID> of the foreign key table SPFLI>>. ... define table spfli { ... @AbapCatalog.foreignKey.label : 'Check Against Airline' @AbapCatalog.foreignKey.keyType : #KEY @AbapCatalog.foreignKey.screenCheck : true key carrid : s_carr_id not null with foreign key [0..*,1] scarr where mandt = spfli.mandt and carrid = spfli.carrid; ... }> ABAP_EXAMPLE_END