ABAP Data Dictionary Exercises
ABAP Data Dictionary Exercises
amin "onventions
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. !his prevents the possibility o" naming con"licts during an upgrade "rom one release o" SAP to another. Also# in the "ollowing e$ercises you will see suggested object names. %ach suggested object name will contain XX or ZZ. !o ensure that objects you create have di""erent names "rom objects that your classmates create# replace the XX or ZZ that you will see in the suggested object names with the last two digits o" your SAP &ogon '(. )*hen you are in a situation# where a dictionary object o" your selected name already e$ists in the system# then as+ the instructor i" you can delete the e$isting one# otherwise as+ him to suggest a new name "or yours., 'n short- .egin all object names with a Y or a Z# and replace the XX or ZZ with the last two digits o" your SAP logon '(.
!he e$ercises "or this chapter will teach you how to create and manipulate the basic objects o" the A.AP (ictionary- tables# data elements# and domains. You will also enter data into one o" your tables# and you will learn how to write a simple program that e$tracts data "rom an A.AP (ictionary table. '" you re4uire assistance at any point# please as+ an instructor. !ry to do the solutions "or the e$ercises yoursel" and i" you "ind any di""iculty consult the hands on instructor. Also# solutions are provided in this boo+# but only re"er to them as a last resort.
Page 1
8arch 1229
"hoose Data%ase Ta%le an+ type ),,E*P in the space provi+e+. Then clic- the "reate %.tton.
Note: !he name o" the table in the A.AP (ictionary does not have to be the same as the name o" the corresponding entity type in the data model. 5owever# in many cases# "or claritys sa+e# it may be logical to ma+e them the same. 5ere# we are naming them the same. Step 3: !he table de"inition screen appears. .egin by entering some o" the tables general attributes- short te$t# (elivery >lass# and whether or not table maintenance is allowed. %nter > "or the (elivery >lass# and clic+ on the !ab.8aint.Allowed "ield. Question 1: *hat is the primary "unction o" the (elivery >lass attribute? *hat does a value o" @> in this "ield indicate? Hint: !urning on the !ab.8aint.Allowed attribute permits the tables data to be edited by S%:A# S%::# ideally you should turn o"" !ab.8aint.Allowed and create a !able 8aintenance =enerator "or the table (See appendi$ to +now about !able 8aintenance =enerator to maintain entries through SAP !able 8aintenance !ransactions such as S8B2 and S8B:.
Page B
8arch 1229
(. Enter a short +escription /or the ta%le. '. Then0 enter 1"2 the Delivery "lass. 3. 3inally0 select Display/*aintenance Allo4e+
Page C
8arch 1229
Step 4: De$t# enter the name o" the "irst "ield in the table. !his will be the %mployee '( Dumber. >all this "ield %8PE'(. Since this "ield is part o" the primary +ey o" this table (in "act# it is the only "ield in the primary +ey o" this table # clic+ on the Fey attribute.
Enter the /irst /iel+ name 7E*P89D:. Then clic- on the #ey attri%.te.
Hint: (epending on your monitor and depending on the "ont you have selected in SAP# you may not see very many "ields in the "ield de"inition area. Hint: Dotice that names o" customer3created fields do not have to begin with a Y or a Z. ;ields only have meaning within the particular table "or which they are de"ined# and they are not individual objects within the A.AP (ictionary. Dames o" customer3created tables# data elements# and domains# however# must begin with a Y or a Z. !ables# data elements# and domains e$ist as individual objects within the A.AP (ictionary. Step 5: De$t# enter the data element "or this "ield. 'n this case# use a new data element called YXX%8PE'(. 7nce you have entered the data element name# double3clic+ on the name o" the data element.
Enter the name o/ the +ata element 7)XXE*P9D:. Then +o.%le;clic- on the name o/ the +ata element
Step 6: (ouble3clic+ing on the name o" the data element brings up the >reate (ata %lement dialog bo$. >lic+ the green chec+ mar+ to indicate that you wish to continue creating the data element. Step 7: De$t# you see the data element de"inition tab. %nter a short te$t. !his will appear beside the name o" the "ield on the table de"inition screen. !hen# enter YXX%8P'( as the domain name.
Page 9
8arch 1229
(. Enter a short +escription. '. Then0 enter )XXE*P9D as the +omain name
Step <: De$t# enter the "ield labels in the ;ield label tab. !hese are the labels that will appear on end3user screens when "ields are /painted0 onto those screens "rom the dictionary. ;ill in short# medium and long "ield labels. 't is also advisable to "ill in a /header0 label (which is used i" the "ield is painted into something +nown as a /table control0 .
Page A
8arch 1229
Enter /iel+s2 la%els: short0 me+i.m0 an+ lon 0 an+ a hea+er la%el
Step =: De$t# double3clic+ on the name o" the domain that you entered in Step G. >lic+ the green chec+ mar+ in the >reate (omain dialog bo$ that appears. Step (>: %nter a short te$t# and a data type and length "or the domain. You may see the various data types available by hitting ;C in the (ata type "ield. ;or this domain# use type >5AH and length :2.
Page G
8arch 1229
Step ((: Dow you are ready to activate your domain. >lic+ the activation symbol on the application toolbar. You will be prompted to enter a pac+age and a change re4uest. A"ter the domain is activated# you will see a message at the bottom o" the screen# and the status o" the domain change to /Active0 and /Saved0.
Page I
8arch 1229
A/ter enterin a Pac-a e ? a chan e [email protected] the stat.s o/ the +omain 4ill chan e.
Hint: A.AP (ictionary 7bjects must be activated be"ore they are visible to other objects in the system. A"ter you ma+e changes to a dictionary object# you must re3activate it. A common mista+e is to revise an object and then "orget to re3activate it. Step (': De$t# clic+ the green arrow to return to your data element. Dow that the domain has been activated# you may activate the data element. >lic+ the activation symbol. %nter your pac+age J change re4uest when prompted. You should see a message at the bottom o" the screen saying that the data element was activated# and the status will change to /Active0 and /Saved0. Step (3: >lic+ the green arrow to return to the table de"inition screen. Hint: '" you are unable to complete your wor+ on a table in one sitting# save the table without activating it (ma+e sure you are on the table de"inition screen . !o return to the table later# go to your pac+age. (rill down through (ictionary objects# and then !ables# until you see the name o" your table. (ouble3clic+ on the table name. !his will bring you bac+ to the table de"inition screen. %nter change mode by clic+ing the (isplayK3<>hange button on the toolbar. !o add new "ields to the table# clic+ the @Dew rows button. You may need to reduce the siLe o" your "ont in order "or the "ield display to wor+ appropriately.
Page M
8arch 1229
To a++ ne4 /iel+s to the ta%le clic- the 1!e4 ro4s 1%.tton .
Page :2
8arch 1229
Step (4: >omplete the de"inition "or table YXX%8P by entering the "ollowing "ields# data elements# and domains. You will create your own data elements "or each "ield. ;or some "ields# you will use pre3de"ined domains# and "or other "ields# you will create your own domains.
Note: !he 5&!5EP&AD "ield is to contain the '( o" the health plan the employee has selected. !his "ield will eventually point to the YXX5%A&!5 table. Note: 'n reality# this table would contain more "ields than this. !o save time# you are only creating these three "ields. Step (5: >lic+ the activation symbol. %nter your Pac+age and >hange re4uest when prompted.
Page ::
8arch 1229
Step (6: !he 8aintain !echnical Settings screen will appear. %nter @NS%H as the data class and @2 as the siLe category. Save the technical settings and clic+ the green arrow. You will return to the table de"inition screen# and the tables status will change to /Active0 and /Saved0.
Secon+0 clic- the save icon. Then0 clic- the reen arro4.
Page :1
8arch 1229
Question 2: *hat does the data class control? *hat does a value o" @NS%H indicate? Question 3: *hat does the siLe category control? 'n this case# what does a value o" @2 represent? Step (7: ;rom the table de"inition screen# clic+ the green arrow to return to the A.AP (ictionary- 'nitial Screen.
P&ADE'( is the health plan '(. (%S>H is a description o" the health plan. ADDEPH%8 is the annual premium "or belonging to this health plan. )XXE$FRC) 3iel+ !ame %8PE'( 57NHEHA!% #ey O Data Element YXX%8P'( YXX57NHHA! Domain YXX%8P'( YXX57NHHA! Type >5AH DN8> Cen th :2 C
Even tho. h type "FRR 4o.l+ %e more appropriate /or E$FRC)8RAT0 the system 4ill not a+minister a chec- on the /ixe+ val.es that yo. 4ill create in /.t.re exercises. )o. 4ill learn ho4 to per/orm necessary chec-s pro rammatically in the next mo+.le. %8PE'( is the employee '(. 57NHEHA!% is the hourly rate the employee is paid. )XXSACAR9ED 3iel+ !ame #e y %8PE'( O SA&AHY Data Element YXX%8P'( YXXSA&AHY Domain YXX%8P'( YXXSA&AHY Type >5AH (%> Cen th :2 I
%8PE'( is the employee '(. SA&AHY is the annual salary the employee is paid.
Page :B
8arch 1229
%8PE'( is the employee '(. DN8ES5AH%S is the number o" shares the partner owns.
Step 6: >lic+ the Save icon to save your changes. !hen clic+ the green arrow to return to the primary domain de"inition screen. Step 7: >lic+ the activation symbol to re3activate your domain.
Page :C
8arch 1229
!he only valid employee '(s are the ones contains in the YXX%8P table. >hange the YXX%8P'( domain so that the value table is listed as YXX%8P. Step (: Proceed to the de"inition screen "or domain YXX%8P'(. %nter change mode. Step ': %nter YXX%8P as the value table in the space provided (about hal"way down the screen .
Step 3: He3activate your domain. Similarly# the only valid health plan '(s are those that are listed in the YXX5%A&!5 table. Step 4: 8odi"y domain YXX5&!5P&D so that the value table is YXX5%A&!5. He3activate the domain when you are "inished.
"hapter 3 Exercises
'n the previous e$ercises# you established the basic objects to be used "or a simpli"ied payroll processing system. 'n addition to establishing the tables# data elements# and domains# you also established value tables "or certain domains in order to ensure data integrity within the system. Dow you will ta+e this a step "urther by establishing appropriate "oreign +eys in the A.AP (ictionary.
Exercise 3.( Esta%lish a 3orei n #ey Relationship %et4een the )XXE*P an+ the )XXE$FRC) Ta%les
Step (: Proceed to the dictionary de"inition o" the YXX57NH&Y table. %nter change mode. Step ': %stablish a "oreign +ey relationship to the YXX%8P table on the %8PE'( "ield. .e sure to speci"y the appropriate cardinality and "oreign +ey "ield type Step 3: *hen you are "inished# re3activate the YXX57NH&Y table.
Page :9
8arch 1229
SAP R/3 Release 4.7 Exercises: The ABAP Dictionary SAP Development ABAP Trainin Exercise 3.' Esta%lish 3orei n #ey Relationships /rom Ta%les )XXSACAR)0 )XXPART!ER0 an+ )XXE*P
Step (: %stablish the "ollowing "oreign +ey relationships3rom: Ta%le YXXSA&AH'%( YXXPAH!D%H YXX%8P 3iel+ %8PE'( %8PE'( 5&!5EP&AD To: Ta%le YXX%8P YXX%8P YXX5%A&!5 3iel+ %8PE'( %8PE'( P&ADE'(
"hapter 4 Exercises
!he purpose o" these e$ercises is to give you "amiliarity with manipulating e$isting tables# their structures# and their data.
Step (: 'n the employee table (YXX%8P # there is o"ten a need to access records by employee name. !o improve the e""iciency o" this process# create a secondary inde$ on the last name and "irst name "ields. (>reate one inde$ @DA8 that sort by last name# then by "irst name.
Page :G
8arch 1229
!he e$ercises "or this chapter will "amiliariLe you with creating and using structures (tables o" type 'D!!A. in SAP.
A((H: is the "irst line o" the address. A((H1 is the second line o" the address. >'!Y is the city. H%='7D is the province or state. P7S!E>7(% is the postal code. >7ND!HY is the country. Step ': Activate the structure Step 3: 'nclude the structure YXXA((H in the table YXX%8P. (o not "orget to re3activate table YXX%8P.
Page :I
8arch 1229
Step 5: Dotice that you now have additional "ields to enter the employees address. %nter an address# and then save your wor+.
"hapter 6 Exercises
!he purpose o" these e$ercises is to give you e$perience using the A.AP Hepository 'n"ormation System. !his "acility can provide a great deal o" in"ormation on objects created and maintained within SAP.
Page :M
8arch 1229
(i.e.
Page 12
8arch 1229
Page 1:
8arch 1229
Exercises: The ABAP Dictionary "hapter < Exercises Exercise <.( "reatin a Gie4
Hint: ;ollow the step3by3step instructions contained in the appendices in your manual as you complete this e$ercise. Step (: Nsing the Nniversity (ata 8odel# create a view that provides an overview o" courses (identi"ied by course number # the course titles# "aculties that o""er them (need both "aculty number and name # and the pro"essors (identi"ied by pro"essor number responsible "or teaching those courses. (e"ine a view (YXXFN that "ul"ills those re4uirements. >hoose the type o" view care"ully. !he re4uirement calls "or multiple tables to be included in the view. 8aintenance status is /H0 "or read3only. !he tables you will need to use are NFNHS and N;A>5. Step ': Nsing the data that e$ists in the tables# test your view via one o" the "ollowing methods*etho+ (: Fse a simple ABAP pro ram. He"er to Appendi$ on view. *etho+ ': Exec.te the Gie4. =o to S%:A. =ive the name o" the view and clic+ on the table contents push button application toolbar. in the
Page 11
8arch 1229
Step (: !he view is now to include course descriptions as well as course titles. You will need to add table NFHS. to your view. !he course descriptions in table NFHS. are languagede!endent. %stablish selection criteria "or the view so that course descriptions are limited to either =erman or %nglish (choose one . Note: >ourse titles# as well as "aculty titles# are not language3dependent# and they only exist in "erman# >ourse descri!tions# however# are in the database in both =erman and %nglish. You must choose which language you would li+e to use in your view.
Page 1B
8arch 1229
Exercises: The ABAP Dictionary "hapter = Exercises Exercise =.( "reatin Search Eelp
&ets assume your employee table is used in a transaction. 8ore than li+ely# you will need to enter the employee '( number rather than the employee name on a screen. You want to provide the user with the ability to search "or the appropriate employee '( based on the employee name. (esign a search help to attach to the employee '( "ield. Step (: >reate an elementary search help using the wor+bench. Dame your search help YXXES%AH>5E5%&P. !he selection method should be your employee table (YXX%8P . Step ': 'ndicate the dialog type setting that will create a comple$ dialog where you can narrow your search. Step 3: Select the appropriate "ields so that your search help will return the employee '( based on the speci"ied employee last or "irst name. Step 4: &ist the %mployee '( and "ull name on this hit list. Step 5: (o not have %mployee '( appear on the comple$ dialog. Step 6: Activate the search help. Step 7: Attach the search help to your employee '( "ield in the YXX%8P table. Step <: !est your search help using the "ollowing methodExec.te the Ta%le. =o to S%:A. =ive the name o" the table YOO%8P and clic+ on the table contents push button in the application toolbar. !he Selection screen appears. Place the cursor on %mployee '( "ield and hit the ;C "unction +ey. IFEST9$!: 5ow would you design a search help to retrieve an employee '( only i" the employee is salaried?
Page 1C
8arch 1229
Page 19
8arch 1229