Abap Data Dictionary Exercises
Abap Data Dictionary Exercises
Abap Data Dictionary Exercises
7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Naming Conventions
SAP has agreed to never create development objects whose names begin with a Y or a Z. SAP
customers (that’s you!) must give all objects that they create names that do begin with a Y or a Z.
This prevents the possibility of naming conflicts during an upgrade from one release of SAP to
another.
Also, in the following exercises you will see suggested object names. Each suggested object
name will contain XX or ZZ. To ensure that objects you create have different names from objects
that your classmates create, replace the XX or ZZ that you will see in the suggested object
names with the last two digits of your SAP Logon ID.
[When you are in a situation, where a dictionary object of your selected name already exists in
the system, then ask the instructor if you can delete the existing one, otherwise ask him to
suggest a new name for yours.]
In short: Begin all object names with a Y or a Z, and replace the XX or ZZ with the last two digits
of your SAP logon ID.
However, if you try to change an SAP-delivered object (or if you forget to name your object
beginning with a Y or a Z), you will be prompted for an Object Access Key. This is because
SAP registers and controls all customer changes to SAP-delivered objects. If you see this dialog
box during this course, you have made a mistake; click the cancel button in the dialog box.
It is easy to confuse a request for a developer access key with a request for an object access key.
One way to remember the difference is to remember the phrase, “You are not a registered
developer.” If the request contains this phrase, it is asking for a developer access key. If it does
not contain this phrase, it is asking for an object access key.
March 2005
Page 1
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Chapter 2 Exercises
The exercises for this chapter will teach you how to create and manipulate the basic objects of
the ABAP Dictionary: tables, data elements, and domains. You will also enter data into one of
your tables, and you will learn how to write a simple program that extracts data from an ABAP
Dictionary table.
If you require assistance at any point, please ask an instructor. Try to do the solutions for the
exercises yourself and if you find any difficulty consult the hands on instructor. Also, solutions are
provided in this book, but only refer to them as a last resort.
This table will store basic information for all employees. All employees will have one entry in this
table.
Step 1: From SAP Initial Screen -> Go to Tools -> ABAP Workbench -> Development -> ABAP
Dictionary (tcode: SE11) to go to the ABAP Dictionary Initial Screen.
Step 2: Choose Database table and type YXXEMP in the space provided (replacing XX with
your 2-digit id). Then click the Create button.
March 2005
Page 2
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Note: The name of the table in the ABAP Dictionary does not have to be the same as the name
of the corresponding entity type in the data model. However, in many cases, for clarity’s sake, it
may be logical to make them the same. Here, we are naming them the same.
Step 3: The table definition screen appears. Begin by entering some of the table’s general
attributes: short text, Delivery Class, and whether or not table maintenance is allowed. Enter C
for the Delivery Class, and click on the Tab.Maint.Allowed field.
Question 1: What is the primary function of the Delivery Class attribute? What does a value of
‘C’ in this field indicate?
Hint: Turning on the Tab.Maint.Allowed attribute permits the table’s data to be edited by SE16,
SE11, ideally you should turn off Tab.Maint.Allowed and create a Table Maintenance Generator
for the table (See appendix to know about Table Maintenance Generator) to maintain entries
through SAP Table Maintenance Transactions such as SM30 and SM31.
March 2005
Page 3
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
March 2005
Page 4
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Step 4: Next, enter the name of the first field in the table. This will be the Employee ID Number.
Call this field EMP_ID. Since this field is part of the primary key of this table (in fact, it is the only
field in the primary key of this table), click on the Key attribute.
Hint: Depending on your monitor and depending on the font you have selected in SAP, you may
not see very many fields in the field definition area.
Hint: Notice that names of customer-created fields do not have to begin with a Y or a Z. Fields
only have meaning within the particular table for which they are defined, and they are not
individual objects within the ABAP Dictionary. Names of customer-created tables, data elements,
and domains, however, must begin with a Y or a Z. Tables, data elements, and domains exist as
individual objects within the ABAP Dictionary.
Step 5: Next, enter the data element for this field. In this case, use a new data element called
YXXEMP_ID. Once you have entered the data element name, double-click on the name of the
data element.
Step 6: Double-clicking on the name of the data element brings up the Create Data Element
dialog box. Click the green check mark to indicate that you wish to continue creating the data
element.
Step 7: Next, you see the data element definition tab. Enter a short text. This will appear beside
the name of the field on the table definition screen. Then, enter YXXEMPID as the domain name.
March 2005
Page 5
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Step 8: Next, enter the field labels in the Field label tab. These are the labels that will appear on
end-user screens when fields are “painted” onto those screens from the dictionary. Fill in short,
medium and long field labels. It is also advisable to fill in a “header” label (which is used if the
field is painted into something known as a “table control”).
March 2005
Page 6
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Step 9: Next, double-click on the name of the domain that you entered in Step 7. Click the green
check mark in the Create Domain dialog box that appears.
Step 10: Enter a short text, and a data type and length for the domain. You may see the various
data types available by hitting F4 in the Data type field. For this domain, use type CHAR and
length 10.
March 2005
Page 7
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Step 11: Now you are ready to activate your domain. Click the activation symbol on the
application toolbar. You will be prompted to enter a package and a change request. After the
domain is activated, you will see a message at the bottom of the screen, and the status of the
domain change to “Active” and “Saved”.
March 2005
Page 8
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Hint: ABAP Dictionary Objects must be activated before they are visible to other objects in the
system. After you make changes to a dictionary object, you must re-activate it. A common
mistake is to revise an object and then forget to re-activate it.
Step 12: Next, click the green arrow to return to your data element. Now that the domain has
been activated, you may activate the data element. Click the activation symbol. Enter your
package & change request when prompted. You should see a message at the bottom of the
screen saying that the data element was activated, and the status will change to “Active” and
“Saved”.
Step 13: Click the green arrow to return to the table definition screen.
Hint: If you are unable to complete your work on a table in one sitting, save the table without
activating it (make sure you are on the table definition screen). To return to the table later, go to
your package. Drill down through Dictionary objects, and then Tables, until you see the name of
your table. Double-click on the table name. This will bring you back to the table definition screen.
Enter change mode by clicking the Display<->Change button on the toolbar. To add new fields to
the table, click the ‘New rows’ button. You may need to reduce the size of your font in order for
the field display to work appropriately.
March 2005
Page 9
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
March 2005
Page 10
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Step 14: Complete the definition for table YXXEMP by entering the following fields, data
elements, and domains. You will create your own data elements for each field. For some fields,
you will use pre-defined domains, and for other fields, you will create your own domains.
Note: The HLTH_PLAN field is to contain the ID of the health plan the employee has selected.
This field will eventually point to the YXXHEALTH table.
Note: In reality, this table would contain more fields than this. To save time, you are only
creating these three fields.
Step 15: Click the activation symbol. Enter your Package and Change request when prompted.
March 2005
Page 11
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Step 16: The Maintain Technical Settings screen will appear. Enter ‘USER’ as the data class
and ‘0’ as the size category. Save the technical settings and click the green arrow. You will
return to the table definition screen, and the table’s status will change to “Active” and “Saved”.
March 2005
Page 12
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Question 2: What does the data class control? What does a value of ‘USER’ indicate?
Question 3: What does the size category control? In this case, what does a value of ‘0’
represent?
Step 17: From the table definition screen, click the green arrow to return to the ABAP Dictionary:
Initial Screen.
Create the YXXHEALTH, YXXHOURLY, YXXSALARIED, and YXXPARTNER tables. Use the
following fields, data elements, and domains. The YXXHOURLY, YXXSALARIED, and
YXXPARTNER tables will each have one entry for every employee assigned to that particular
type of earnings. Each employee must belong to one and only one type of earnings table. The
YXXHEALTH table has one entry for each type of health plan to which the employees could
belong.
Important Note: As of SAP Release 4.6C, you may not have a table and a data element
with the same name.
YXXHEALTH
Field Name Ke Data Element Domain Type Length
y
PLAN_ID X YXXHLTHPLN YXXHLTHPLN NUMC 4
DESCR YXXDESCR YXXDESCR CHAR 80
ANN_PREM YXXANNPREM YXXANNPREM DEC 6
YXXHOURLY
Field Name Key Data Element Domain Type Length
EMP_ID X YXXEMPID YXXEMPID CHAR 10
HOUR_RATE YXXHOURRAT YXXHOURRAT NUMC 4
Even though type CURR would be more appropriate for HOURLY_RAT, the system will not
administer a check on the fixed values that you will create in future exercises. You will
learn how to perform necessary checks programmatically in the next module.
EMP_ID is the employee ID.
HOUR_RATE is the hourly rate the employee is paid.
YXXSALARIED
Field Name Ke Data Element Domain Type Length
y
EMP_ID X YXXEMPID YXXEMPID CHAR 10
SALARY YXXSALARY YXXSALARY DEC 8
March 2005
Page 13
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
SALARY is the annual salary the employee is paid.
YXXPARTNER
Field Name Ke Data Element Domain Type Length
y
EMP_ID X YXXEMPID YXXEMPID CHAR 10
NUM_SHARES YXXNUMSHAR DEC7 pre-defined pre-defined
Valid values for domains can be restricted two ways: by explicitly listing (“hard-coding”) fixed
values in the domain itself, and by specifying a value table.
Hourly employees are always paid between $5.00 and $35.00 per hour. Explicitly list this
restriction in the domain for the hourly rate.
Step 1: From SAP Initial Screen -> Go to Tools -> ABAP Workbench -> Development -> ABAP
Dictionary (tcode: SE11) to go to the ABAP Dictionary Initial Screen.
Step 2: Choose Domain and type YXXHOURRAT in the space provided (replacing XX with your
2-digit id).
Step 5: Enter 5 as the lower limit and 35 as the upper limit. Enter a short text describing the
limit.
Step 6: Click the Save icon to save your changes. Then click the green arrow to return to the
primary domain definition screen.
March 2005
Page 14
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
The only valid employee ID’s are the ones contains in the YXXEMP table. Change the
YXXEMPID domain so that the value table is listed as YXXEMP.
Step 1: Proceed to the definition screen for domain YXXEMPID. Enter change mode.
Step 2: Enter YXXEMP as the value table in the space provided (about halfway down the
screen).
Similarly, the only valid health plan ID’s are those that are listed in the YXXHEALTH table.
Step 4: Modify domain YXXHLTHPLN so that the value table is YXXHEALTH. Re-activate the
domain when you are finished.
Chapter 3 Exercises
In the previous exercises, you established the basic objects to be used for a simplified payroll
processing system. In addition to establishing the tables, data elements, and domains, you also
established value tables for certain domains in order to ensure data integrity within the system.
Now you will take this a step further by establishing appropriate foreign keys in the ABAP
Dictionary.
Step 1: Proceed to the dictionary definition of the YXXHOURLY table. Enter change mode.
Step 2: Establish a foreign key relationship to the YXXEMP table on the EMP_ID field. Be sure
to specify the appropriate cardinality and foreign key field type
March 2005
Page 15
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Exercise 3.2 Establish Foreign Key Relationships from Tables YXXSALARY,
YXXPARTNER, and YXXEMP
From: To:
Table Field Table Field
YXXSALARIED EMP_ID YXXEMP EMP_ID
YXXPARTNER EMP_ID YXXEMP EMP_ID
YXXEMP HLTH_PLAN YXXHEALTH PLAN_ID
Chapter 4 Exercises
The purpose of these exercises is to give you familiarity with manipulating existing tables, their
structures, and their data.
Step 1: From SAP Initial Screen -> Go to Tools -> ABAP Workbench -> Development -> ABAP
Dictionary (tcode: SE11) to go to the ABAP Dictionary Initial Screen.
Step 2: Choose Database table and type YXXEMP in the space provided (replacing XX with
your 2-digit id).
Step 3: Click the Copy icon on the application toolbar. In the dialog box that appears, enter
YXXEMP_CP as the new table name. Then click the green check mark.
Step 5: Go to SE11 again and open the newly created table YXXEMP_CP and activate it.
Question 1: To what package does the SAP standard table KUNNR belongs?
March 2005
Page 16
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Step 1: Create two fictitious health plans. Give them ID’s, names (descriptions), and annual
premiums.
Step 2: Create three fictitious employees. Make one a partner, one a salaried employee, and
one an hourly employee. Give each one of them, appropriate pay information. (You will need to
access four tables: YXXEMP, YXXPARTNER, YXXSALARIED, and YXXHOURLY.)
Note: It is also possible to add entries to a table by accessing the table through your package.
Go into the ABAP Dictionary: Change Table/Structure Fields screen and choose menu option
Utilities 🡪 Table contents 🡪Create Entries.
March 2005
Page 17
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Chapter 5 Exercises
The exercises for this chapter will familiarize you with creating and using structures (tables of type
INTTAB) in SAP.
Step 1: Create the structure YXXADDR. (In SE11 select radio button ‘Data Type’ and select
‘Structure’ in the popup that appears.
YXXADDR
Field Name Data Element Domain Type Length
ADDR1 YXXADDR1 CHAR50 Pre-defined Pre-defined
ADDR2 YXXADDR2 CHAR50 Pre-defined Pre-defined
CITY YXXCITY CHAR50 Pre-defined Pre-defined
REGION YXXEGION CHAR10 Pre-defined Pre-defined
POST_CODE YXXPOSTCD CHAR15 Pre-defined Pre-defined
COUNTRY LAND1_GP Pre-defined Pre-defined Pre-defined
Step 3: Include the structure YXXADDR in the table YXXEMP. Do not forget to re-activate table
YXXEMP.
Step 2: Enter YXXEMP as the table name and click the Display push button on the toolbar.
Step 3: A selection screen appears. Click the Execute push button on the toolbar (or hit F8)
without entering any selection criteria.
Step 4: Choose one of your entries, and then click the Change push button on the toolbar.
March 2005
Page 18
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Step 5: Notice that you now have additional fields to enter the employee’s address. Enter an
address, and then save your work.
Chapter 6 Exercises
The purpose of these exercises is to give you experience using the ABAP Repository Information
System. This facility can provide a great deal of information on objects created and maintained
within SAP.
Step 1: Create and print a list of all tables in the university model. Tables in this data model all
have names beginning with the letter U. Their delivery class is A.
Step 2: Choose one table from the result list for Step 1. For that table, find the list of all fields,
domains, and data elements used in that table.
March 2005
Page 19
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Exercise 6.3 Finding Tables that are related to One Another
Step 1: In the customer master tables the country key is kept in table KNA1. Find the table
where the country description/name is kept (e.g., for country key US --> United States).
Note: This exercise is especially similar to the type of research you may be required to do on a
project.
Hints:
1) Concentrate on the foreign key relationship.
2) Related tables are often named with the same base prefix and a different suffix (i.e.
TXXX, TXXXA, TXXXB would all be related text tables).
March 2005
Page 20
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Chapter 7 Exercises
Step 2: Re-activate the YXXCITY data element. You may get a warning about the length of the
header label. If so, hit Enter to navigate past this warning.
Step 3: Next you will see a warning that dependent tables may need to be converted. Click
Continue.
Step 4: Next you will see a log of messages from the Database Utility. These messages will tell
you that it was possible to successfully alter/adjust the YXXADDR structure and the YXXEMP
table.
March 2005
Page 21
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Chapter 8 Exercises
Step 1: Using the University Data Model, create a view that provides an overview of courses
(identified by course number), the course titles, faculties that offer them (need both faculty
number and name), and the professors (identified by professor number) responsible for teaching
those courses. Define a view (YXXKU) that fulfills those requirements.
Choose the type of view carefully. The requirement calls for multiple tables to be included in the
view. Maintenance status is “R” for read-only. The tables you will need to use are UKURS and
UFACH.
Step 2: Using the data that exists in the tables, test your view via one of the following methods:
March 2005
Page 22
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Exercise 8.2 Changing a View
Step 1: The view is now to include course descriptions as well as course titles. You will need to
add table UKRSB to your view. The course descriptions in table UKRSB are
language-dependent. Establish selection criteria for the view so that course descriptions are
limited to either German or English (choose one).
Note: Course titles, as well as faculty titles, are not language-dependent, and they only exist in
German. Course descriptions, however, are in the database in both German and English. You
must choose which language you would like to use in your view.
March 2005
Page 23
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Chapter 9 Exercises
Step 1: Create an elementary search help using the workbench. Name your search help
YXX_SEARCH_HELP. The selection method should be your employee table (YXXEMP).
Step 2: Indicate the dialog type setting that will create a complex dialog where you can narrow
your search.
Step 3: Select the appropriate fields so that your search help will return the employee ID based
on the specified employee last or first name.
Step 4: List the Employee ID and full name on this hit list.
Step 7: Attach the search help to your employee ID field in the YXXEMP table.
QUESTION: How would you design a search help to retrieve an employee ID only if the
employee is salaried?
March 2005
Page 24
SAP R/3 Release 4.7
Exercises: The ABAP Dictionary SAP Development ABAP Training
Chapter 10 Exercises
You will add documentation to your tables YXXEMP and YXXHEALTH. Pick a field from each
table. (E.g. EMP_ID from YXXEMP and PLAN_ID from YXXHEALTH)
Step 1: Maintain the documentation for the data elements. (E.g. YXXEMPID and YXXHLTHPLN)
Step 2: Maintain supplemental documentation for the data element. Follow instructions in
Chapter 11 of your manual to create data element supplemental documentation.
March 2005
Page 25