What Are Data Elements and Domains?
What Are Data Elements and Domains?
DELETE, INSERT
Domain describes the technical attributes such as data type and length of a table field.
Data Element gives the field labels and documentation for the table field.
Consider the following code. PARAMETERS is the keyword to create input fields.
PARAMETERS: p_matnr TYPE matnr.
Output
In order to get the field labels use the menu in the ABAP editor GOTO->Text Elements->Selection Texts.
The Text ( Field Label ) will be automatically read from the Data Element. Now save, activate, go back and run
the program again.
Now place the cursor on the input field and press F1 key to get the documentation from the data element.
Actually this field label and documentation are maintained in the Data Element MATNR.
So if we want to create a table with two fields as FirstName and SecondName, then only one domain is
sufficient with data type as CHAR and length say 20. But we need two different data elements in order to
display different field labels and documentation for both the fields.
Select the Domain radio button, enter the the name of the domain that you want to create and press create.
Enter the short description. Place the cursor in the data type and press F4 to get the list of SAP data types.
Enter the number of characters. Enter the decimal places if it applicable to data type that you have selected.
Save and activate the domain.
Select the Data type radio button, enter the name of the data element and press create.
Enter short description. Assign a domain to the data element. Press field label tab to maintain the field labels for
thedata element.
Enter the field labels, Save and activate the data element.
Enter a proper short description for the table and maintain delivery class as A'(Application Table). Now press on
Fields tab to maintain the fields of the table.
Enter the fields of the table and maintain the proper data elements for the table fields. You can use the standard
data elements or you can create your own data elements.
Maintain the primary key and press save. To maintain the technical attributes of table like tablespace, size etc.
press the Technical attributes button on application toolbar.
If
is
disabled
then
go
to
Delivery
and
Maintenance
Save and activate the table. Then go back to menu path Utilities->Table Contents->Create Entries.
tab
and
Observe the message in the status bar. To display the values in the table go to Utilities->Table Contents>Display
In the selection screen enter the selection criteria if you want to filter the records you want to display and press
execute.
All
the
records
in
the
table
will
be
displayed
if
no
selection
criteria
specified
DEPARTMENT_NAME
(PRIMARYKEY)
01
Computers
02
Physics
03
Electronics
Employee Table
EMPLOYEE_ID
NAME
PLACE
(PRIMARY KEY)
001
Jim
New York
002
Jack
London
003
Robin
Sydney
004
Raj
Bangalore
If you want to link department table and employee table, then add the primary key of department table i.e.
Department_ID to employee table. Department_ID becomes the foreign key of employee table and Department
table becomes the check table.
Employee table after creating foreign key.
EMPLOYEE_ID
NAME
PLACE
(PRIMARY KEY)
DEPARTMENT_ID
(FOREIGN KEY)
001
Jim
New York
01
002
Jack
London
01
003
Robin
Sydney
02
004
Raj
Bangalore
03
The main purpose of the foreign key is data validation. This will not allow entering a Department_ID in the
employee table that is not there in the department table. For example if you try to create a record in employee
table with Department_ID as 04, it will throw an error.
Step 2: In the popup window enter the check table name and press Generate proposal button.
Step 3: The system proposes the foreign key relation based on the domain. Check that the foreign key
relationship proposed by the system is correct and press copy.
Foreign key is created, now save and activate the table. To check the foreign key go to menu path Utilities>Table Contents->Create Entries.
Try to create an entry in Zemployee table with Department ID that is not there in the Department table. Enter
the values and try to save the entry.
Observe the error message in the status bar. The user interface does the foreign key validation before creating
the entries.