Dictionary ChapterExercise


0x08 graphic
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.

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.

Developer Access Keys vs. Object Access Keys

The first time you try to create an object in SAP, the system will respond with a dialog box that says, “You are not a registered developer.” The dialog box will prompt you for a 20-digit Developer Access Key. This is the access key that appears on the same sheet of paper where you found your logon ID and password. The request for a developer access key will only appear once. After you enter the key correctly, you will not be prompted for it again.

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.

The following exercises are designed to help you understand the ABAP Data Dictionary.

Before you begin the Data Dictionary, you must create a new Development Class and a new Change Request so your work is stored as it might be on a client project. To do this, find the sheet used for your first Development Class and Change Request Exercise and use this if you need it to help you through the abbreviated instructions below:

Create a new Development Class, by going to the Object Navigator (transaction SE80), pull down WORKBENCH from the top menu bar. Select other object, select tab OTHER and typing YXXA in the development Class field (where XX is the last two digits of your logon id). It is important that we all adhere to this naming convention to avoid any future naming conflict with other students.

Click the create button (fourth button at the bottom of the object section screen or F5 and create the new Development Class. Type in a short description, for example; `Data Dictionary Development Class for <your name>'.

NOTE: When you hit the save button, do not use your previous Change Request. Instead, if the Change Request Query Screen appears, click on the Create Request pushbutton, enter a short description, such as `Introduction to ABAP Change Request for <your name>', and save.

Write down the number of your change request here:­ ____________________________

Use the green arrow to go back to your new Development Class, and ensure that all your programs in the Data Dictionary section of the course are stored in this Development Class.

The solutions for the programs can be found in development class “YDATADICTIONARY”. Written solutions can be found in your ABAP manuals.

Exercise (Chapters 2):

In this exercise, you will create and manipulate the basic objects of the ABAP Dictionary: tables, data elements, and domains.

Objectives

After completing this exercise, you will be able to:


If you need help with this exercise, the solutions can be found in Development Class YDATADICTIONARY.

Estimated time to complete this exercise: 60 minutes

Exercises

The following exercises provide practice working with the concepts learned in Chapter 2.

Exercise: Creating a Dictionary Table

In this exercise, you will create tables in the ABAP dictionary to hold customer information.

Chapter 2, Exercise 1

You will be creating two Dictionary tables. You will also create data elements and domains for each field in the tables. The YXXCUSTMASTER table will store basic customer information. Each customer will have one entry in this table. The second table you will create is the YXXCUSTDISCOUNT table. This table will hold customers who receive a discount on all purchases. Let's begin creating our tables.

0x08 graphic
0x08 graphic
0x08 graphic
Step 1. Go to your Objection Navigator screen (SE80). Click on the Other Object Icon. Choose the Dictionary tab. Type YXXCUSTMASTER in the space provided (replacing XX with your 2-digit id) and click the Create button.

0x08 graphic
0x08 graphic

Step 2. The Dictionary: Maintain Table 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?

0x08 graphic
Hint: Turning on the Tab.Maint.Allowed attribute permits the table's data to be edited by standard SAP table maintenance transactions such as SM30, SM31, and SE16. (Note: If you wish to maintain a table via transaction SM31, the table name must be five characters or less).

0x08 graphic
0x08 graphic
0x08 graphic
0x01 graphic
Step 3. Next, select the "Fields" tab and enter the name of the first field in the Fields column as CUST_NUM. 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.

0x01 graphic

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. You can change this by making your font smaller. To do that, select Options from the Paint Palette menu. Then click on the Fonts tab. Now you can select a new fixed font. After changing the fixed font, you will have to fill in a new variable font as well.

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 an Y or a Z. Tables, data elements, and domains exist as individual objects within the ABAP Dictionary.

Step 4. Next, we will create the data element for this field. In this case, use a new data element called YXXCUSTNUM. Tab over to the field type or select data element/direct type and enter the name of the element.

0x08 graphic
0x08 graphic
0x01 graphic

Step 5. Now you need to create the data element YXXCUSTNUM. To do this, simply double-click on the name of the data element. If a window that says "Save before terminating editing?" pops up, click "yes" on that pop-up window to save your changes. If a window titled "Create Object Directory Entry" shows up, verify the development class is YXXA and hit save. If you are prompted for a Change Request, make sure it is the same change request you wrote down earlier in this lab and click the green check box.

Step 6. You will then see a pop-up that says "Data element YXXCUSTNUM not available. Create data element". Click "Yes".

0x08 graphic
Step 7. Enter a short text and domain for the Data Element.

Step 8. Now you need to create the Domain. As before, double click on the Domain YXXCUSTNUM. Click "Yes" at the window that says "Domain YXXCUSTNUM not available, Create the domain?".

Step 9. Enter a short text, and a data type and length for the domain. You can see various data types available by pressing F4 in the Data type field. Enter a short text and Domain name. For this domain, use type CHAR and length 10.

0x01 graphic

Step 10. Click the "Activate" button to activate this domain.

Hint: In SAP, when you Activate an object, it will automatically save and check the object before it is activated.

Step 11. Once your Domain has been activated, click the green back error (or F3) to go back to the Data Element.

Step 12. Once you are back on the "Maintain: Data Element" screen, select 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”).

0x01 graphic

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 13. Now that all the information for your Data Element has been entered and the Domain has been activated, you are ready to activate your Data Element. Click the activation symbol. Enter your development class & 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”.

Step 14. 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 development class. 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, select Edit -> New Fields from the menu. You may need to reduce the size of your font in order for the field display to work appropriately.

Step 15. Complete the definition for table YXXCUSTMASTER by entering the following fields, data elements, and domains. You will create your own data elements for each field. For these particular fields, you will use pre-defined domains. These domains have been created by SAP. Notice that the name does not begin with a Y or a Z.

Field Name

Data Element

Domain

Type

Length

FIRST_NAME

YXXFIRSTNAME

CHAR25

pre-defined

pre-defined

LAST_NAME

YXXLASTNAME

CHAR25

pre-defined

pre-defined

0x08 graphic
Hint: To insert a new row into the table, click the "New rows" button.

0x08 graphic

Step 16. Once you have activated the two new Data Elements, you can activate your table. To activate your table, make sure you are on the "Dictionary: Maintain Table" screen and click the activation symbol. Enter your change request when prompted.

0x08 graphic
0x08 graphic
0x08 graphic
0x01 graphic

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 BACK arrow. You will return to the table definition screen, and the table's status will change to “Active” and “Saved”.

0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x01 graphic

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 your development class.

Hint: Sometimes a newly created object will not appear in your development class. If this happens, select Edit -> Refresh object list from the menu in the Object Navigator.

Step 18. Now create the YXXCUSTDISCOUNT table. Use the following fields, data elements, and domains. The YXXCUSTDISCOUNT table will have one entry for every customer who receives a discount.

*Important Note: As of SAP Release 4.0, you may have a table and a data element with the same name.

YXXCUSTDISCOUNT

Field Name

Key

Data Element

Domain

Type

Length

CUST_NUM

X

YXXCUSTNUM

YXXCUSTNUM

CHAR

10

DIS_PERCENT

YXXDISCOUNT

YXXDISCOUNT

NUMC

2

CUST_NUM is the customer number.

DIS_PERCENT is the percentage discount the customer receives on all orders.

0x01 graphic

Chapter 2, Exercise 2

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.

Customers who are entitled to a discount always receive between 5 and 50% off the total price of their purchase. Explicitly list this restriction in the domain for the percent discount.

Step 1. If you are not there already, go to your development class in the Object Navigator. Refresh your object list.

Step 2. Drill down through your development class until you come to the list of domains (Dictionary objects -> Domains). Double-click on the entry for YXXDISCOUNT.

Step 2. Enter change mode by clicking the Display<->Change button on the application toolbar.

Step 4. Select the Value Range tab.

0x08 graphic
Step 5. Enter 5 as the lower limit and 50 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.

Step 7. Click the activation symbol to re-activate your domain.

Chapter 2, Exercise 3

Now you will limit a domain's values by adding a value table. The only valid customer numbers are the ones contained in the YXXCUSTMASTER table. This means that an end user would only be permitted to add a customer number to the YXXCUSTDISCOUNT table that already exists in the YXXCUSTMASTER table. Change the YXXCUSTNUM domain so that the value table is listed as YXXCUSTMASTER.

Step 1. Proceed to the definition screen for domain YXXCUSTNUM. Enter change mode.

Step 2. Enter YXXCUSTMASTER as the value table in the space provided .

0x01 graphic

Step 3. Re-activate your domain.

0x01 graphic

The ABAP Dictionary ABAP Exercises

0x01 graphic

August, 2001

p:\instruct\courses\abap\bc030\Ch2Ex.doc Page 6

Select Dictionary Tab

Enter a short description for the table.

Then, enter `C' as the Delivery Class.

Finally, click on the Tab.Maint.Allowed field (so that a check appears in the box).

Enter the name of the data element (YXXCUSTNUM).

Other Object

Your screen should look like this. Click the Activate button.

Second, click the save icon. Then, click the green arrow.

First, enter the data class and size category.

0x01 graphic

Exercise

Chapter 2



Wyszukiwarka

Podobne podstrony:
Dictionary Chapter 07
Dictionary ChapterExercise
Dictionary ChapterExercise
Dictionary Chapter 02
Dictionary ChapterExercise
Dictionary Chapter 03
Dictionary ChapterExercise
Dictionary Chapter 01
Dictionary Chapter 04
Dictionary Chapter 08
Dictionary Chapter 05

więcej podobnych podstron