Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SAP has agreed to never create development objects whose names begin with a Y or a Z. SAP customers (thats 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.
Chapter 2 Exercises
Page 1 March 2005
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.
Page 2
March 2005
Choose Database Table and type YXXEMP in the space provided. Then click the Create button.
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 claritys 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 tables 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 tables 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.
Page 3
March 2005
1. Enter a short description for the table. 2. Then, enter C the Delivery Class. 3. Finally, select Display/Maintenance Allowed
Page 4
March 2005
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.
Enter the first field name (EMP_ID). Then 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.
Enter the name of the data element (YXXEMPID). Then 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.
Page 5
March 2005
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).
Page 6
March 2005
Enter fields labels: short, medium, and long, and a header label
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.
Page 7
March 2005
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.
Page 8
March 2005
After entering a Package & a change request, the status of the domain will change.
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.
Page 9
March 2005
To add new fields to the table click the New rows button.
Page 10
March 2005
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.
Page 11
March 2005
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 tables status will change to Active and Saved.
Second, click the save icon. Then, click the green arrow.
Page 12
March 2005
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.
PLAN_ID is the health plan ID. DESCR is a description of the health plan. ANN_PREM is the annual premium for belonging to this health plan. YXXHOURLY Field Name EMP_ID HOUR_RATE Key X Data Element YXXEMPID YXXHOURRAT Domain YXXEMPID YXXHOURRAT Type CHAR NUMC Length 10 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 y EMP_ID X SALARY Data Element YXXEMPID YXXSALARY Domain YXXEMPID YXXSALARY Type CHAR DEC Length 10 8
EMP_ID is the employee ID. SALARY is the annual salary the employee is paid.
Page 13
March 2005
EMP_ID is the employee ID. NUM_SHARES is the number of shares the partner owns.
Step 6: Click the Save icon to save your changes. Then click the green arrow to return to the primary domain definition screen. Step 7: Click the activation symbol to re-activate your domain.
Page 14
March 2005
The only valid employee IDs 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).
Step 3: Re-activate your domain. Similarly, the only valid health plan IDs 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.
Exercise 3.1 Establish a Foreign Key Relationship between the YXXEMP and the YXXHOURLY Tables
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 Step 3: When you are finished, re-activate the YXXHOURLY table.
Page 15
March 2005
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
Step 1: Establish the following foreign key relationships: From: Table YXXSALARIED YXXPARTNER YXXEMP Field EMP_ID EMP_ID HLTH_PLAN To: Table YXXEMP YXXEMP YXXHEALTH Field EMP_ID EMP_ID 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: In the employee table (YXXEMP), there is often a need to access records by employee name. To improve the efficiency of this process, create a secondary index on the last name and first name fields. (Create one index NAM that sort by last name, then by first name.)
Page 17
March 2005
The exercises for this chapter will familiarize you with creating and using structures (tables of type INTTAB) in SAP.
ADDR1 is the first line of the address. ADDR2 is the second line of the address. CITY is the city. REGION is the province or state. POST_CODE is the postal code. COUNTRY is the country. Step 2: Activate the structure Step 3: Include the structure YXXADDR in the table YXXEMP. Do not forget to re-activate table YXXEMP.
Page 18
March 2005
Step 5: Notice that you now have additional fields to enter the employees 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.
Page 19
March 2005
(i.e.
Page 20
March 2005
Page 21
March 2005
Exercises: The ABAP Dictionary Chapter 8 Exercises Exercise 8.1 Creating a View
Hint: Follow the step-by-step instructions contained in the appendices in your manual as you complete this exercise. 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: Method 1: Use a simple ABAP program. Refer to Appendix on view. Method 2: Execute the View. Go to SE16. Give the name of the view and click on the table contents push button application toolbar. in the
Page 22
March 2005
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 languagedependent. 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.
Page 23
March 2005
Exercises: The ABAP Dictionary Chapter 9 Exercises Exercise 9.1 Creating Search Help
Lets assume your employee table is used in a transaction. More than likely, you will need to enter the employee ID number rather than the employee name on a screen. You want to provide the user with the ability to search for the appropriate employee ID based on the employee name. Design a search help to attach to the employee ID field. 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 5: Do not have Employee ID appear on the complex dialog. Step 6: Activate the search help. Step 7: Attach the search help to your employee ID field in the YXXEMP table. Step 8: Test your search help using the following method: Execute the Table. Go to SE16. Give the name of the table YXXEMP and click on the table contents push button in the application toolbar. The Selection screen appears. Place the cursor on Employee ID field and hit the F4 function key. QUESTION: How would you design a search help to retrieve an employee ID only if the employee is salaried?
Page 24
March 2005
Page 25
March 2005