Académique Documents
Professionnel Documents
Culture Documents
Prepared by J Kreie
New Mexico State University
ABAP Tables, Data Elements and Domains
This lesson covers creation of ABAP Dictionary definitions for domains and data elements and using these in
defining the fields in a new table. Later, you will create a program to display the table contents and a program to
add data to the table.
Domains and Data Elements
Lets start by taking a look at some metadata in the ABAP Dictionary. Metadata is data about the data in a
database. For example, the metadata about a table would be the table name, the names of fields in the table,
the attributes of each fielddata type, field size, and so on.
Open the ABAP Dictionary (Tools....ABAP Workbench
DevelopmentABAP Dictionary [SE11]). View the table used in
the previous lesson from the flights database: s
STRAVELAG
Click the Value Range tab and you see the three
possible entries for employee gender: M, F, and
N.
Return to the ABAP Dictionary: Initial Screen and start the value
search again. Search for *country code* in the Short
Description field.
Select the domain INTCA3 and display this domain. INTCA3 is a 3-character string (Definition tab) used in the
SZAD package (Properties tab). This 3-character definition provides for space to store codes assigned by the
International Standards Organization (ISO) for each country (see http://en.wikipedia.org/wiki/ISO_31661#Current_codes). For example, the 3-character code for Albania is ALB and the code for Belize is BLZ.
Now weve seen a few examples of domains in the ABAP Dictionary but what is a domain exactly? In relational
database terms, a domain is the definition of a data type. The domain specifies the type of data (character,
numeric, etc.) and may specify a value range, such as the gender example above. As a programmer, you can
Page 2 of 10
. Accept the default settings in the next dialog box and click the
You see some data elements that
use the INTCA3 domain.
Page 3 of 10
In preparation for building the tables first you will create domains and data elements for the type of data your
table will store. For the purpose of learning how to create domains and data elements, you will not use existing
domains in the ABAP Dictionary though youll do so a bit later.
Return to the ABAP Dictionary initial screen (SE11). Check the
Domain radio button and type a domain name using this
template: Z_$$$$_level. Click the Create button.
Enter the short description, data type and number of characters,
as shown here. Save the domain to your lessons package and
transport request.
Check and activate this domain.
Repeat this process in order to create the following domains. Save and activate each one.
Page 4 of 10
Data Type
CHAR
NUMC *
CHAR
CHAR
CHAR
No. Char
12
5
12
15
18
Short Description
Education level description
Identification code
First name
Last name
Education major
* The NUMC datatype is for character data that are numeric characters only (like a zip code).
Use the ABAP Dictionary initial screen to retrieve and display the
domain you created for education major. Select the Value Range
tab. Enter the text shown here.
Save and activate this domain with these changes.
Page 5 of 10
Create the remaining data elements shown below. Be sure to add field labels. You do not have to add the
documentation for each element but you can do so, if you wish.
Save and activate these data elements.
Data Element Name
Z_$$$$_level_desc
Z_$$$$_StudentID
Z_$$$$_firstname
Z_$$$$_lastname
Z_$$$$_educ_major
Short Description
Description of education level
Student Identification Code
Students first name
Students last name
Students major
In the Object Navigator, notice that the domains and data elements
created are now listed in your package. Note, though, that the
example list shown here has data elements in a different color.
This is very helpful! The first two data elements listededucation
major and education levelare not active. They have either
never been activated or theyve been modified and saved but not
activated. Its easy to forget to activate something.
Domain
Z_$$$$_level_desc
Z_$$$$_ID
Z_$$$$_fname
Z_$$$$_lname
Z_$$$$_edu_major
you
re-
Page 6 of 10
Use the SAP menu bar to select: Extras Enhancement Category. Youll
probably get a message that you need to select an enhancement category;
proceed by clicking the checkmark. Click the checkmark to accept the default
setting: Can be enhanced.
Save the table to your transport package. Do not worry if you get a message
about tables being client specific. The client specific message occurs
because you should always include a field in any table you build for the SAP
Page 7 of 10
Remember data model these two tables are based on? This model
shows that the student table has a foreign key field related to the
education level table. Now, youll designate the foreign key in the
student table. Click the STUDENTLVL field to select it then click the
foreign key icon
. For the Short Text enter Students education
level. For the Check Table, use the value search icon to locate
and select the EduLevel table you created.
Next, click the Generate proposal icon
. ABAP Workbench will look at the metadata the
EduLevel table and retrieve the name of the primary key field. Click the checkmark.
Set the enhancement category for this table through the SAP menu bar: Extras Enhancement Category.
Select Can be enhanced and click the checkmark.
Click the Technical Settings button. Set the Data class for APPL0 (Master data, transparent tables). Set the
Size category for 1. Save these settings and return to the table screen.
Save, check and activate this table. Again, dont worry about the client specific warning.
In the next lesson youll create programs to add data to your tables and to display the data.
Page 8 of 10
Practice
Create two tables based on the following data model. Create the necessary domains and data elements and
use these in the tables. The registration table has a date field, which you havent defined before. Use the DATS
data type with a size of 8.
Terms to Know
ABAP Dictionary..................................................................................................................................................... 1
data element........................................................................................................................................................... 2
domain.................................................................................................................................................................... 2
metadata................................................................................................................................................................. 1
Page 9 of 10
References
An Introduction to Database Management Systems. C. J. Date, Addison-Wesley, 8th edition, 2003.
Database in Depth: Relational Theory for Practitioners. C. J. Date, OReilly Media, 2005.
ABAP Basics. Gnther Frber and Julia Kirchner, SAP Press - Galileo Press, 2007.
Discover ABAP. Karl-Heins Khnhauser, SAP Press, 2007.
ABAP Objects: An Introduction to Programming SAP Applications. Horst Keller and Sascha Kruger, SAP Press,
2002.