Abap 017 Tables Data Elements Domains

  • Upload
    ly-bang

  • View
    221

  • Download
    0

Embed Size (px)

Citation preview

  • 8/19/2019 Abap 017 Tables Data Elements Domains

    1/10

    ABAP Tables, Data Elements and DomainsPrepared 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 indefining the fields in a new table. Later, you will create a program to display the table contents and a program toadd data to the table.

    Domains and Data Elements

    Lets start by ta!ing a loo! at some metadata in the ABAP Dictionary. "etadata is data about the data in adatabase. #or e$ample, the metadata about a table would be the table name, the names of fields in the table,the attributes of each field%data type, field si&e, and so on.

    'pen the ABAP Dictionary (Tools....ABAP )or!bench*Development*ABAP Dictionary +E--/. 0iew the table used inthe previous lesson from the flights database1 sT2A0ELA3

    4lic! the Display button and youll see themetadata about T2A0ELA3%the columnnames, data types, field lengths, and more.

    5se the Bac! button to return to theinitial screen for the ABAP Dictionary.

    6ow, well loo! at a domain. elect the radio button ne$t

    to Domain and open the value search for Domain (clic!the bo$ and hit #7/. Type 8employee9 between asteris!s.

    #rom the list of domains shown, find and select P:;

  • 8/19/2019 Abap 017 Tables Data Elements Domains

    2/10

  • 8/19/2019 Abap 017 Tables Data Elements Domains

    3/10

    ABAP Tables, Data Elements and DomainsPrepared by J Kreie

    New Mexico State University 

    thin! of a domain as analogous to a class. To carry this analogy further, you could thin! of the domain as the8class9, the data element as the 8obFect9 based on that class. (ee 4. G. Dates articles or boo!s for more aboutthe role of domains in relational databases./ A data element is based on a domain, so it has the same data typeand field si&e as the domain, but the data elements adds conte$tspecific or situationspecific information. o,the domain is the generic, standard data type definition and the data element customi&es this for a specificsituation.

    Loo! at an e$ample of data element. )ith the domain =6T4A@ still showing in the Dictionary1 Display Domain

    screen, clic! the 8whereused9 icon . Accept the default settings in the ne$t dialog bo$ and clic! thechec!mar!.

    Hou see some data elements thatuse the =6T4A@ domain.

    5sing forward navigation, doubleclic! thePT20

  • 8/19/2019 Abap 017 Tables Data Elements Domains

    4/10

    ABAP Tables, Data Elements and DomainsPrepared by J Kreie

    New Mexico State University 

    The #ield Label tab shows how APdetermines what te$t to display with this dataelement depending on the space available in ascreen.

    The field labels provide meaningful, situationspecific te$t for the field in a table that isassigned this data element.

    Hou can also create features for a dataelement, such as help documentation. =f youdo this, then when a user selects a field basedon this data element then hits the #- !ey, the help te$t you created will appear.

     Another e$ample of a domain and data elements would be to create a 8mail code9 (&ip code/ domain. Two dataelements%mailing address code and shipping address code%would reference the same domain but the labels,the situationspecific te$t would be set for each data element.

    4reate domains

     A little later in this lesson you will build a few tables. Below is a model of two tables you will build. These tableshave no practical purpose in AP but building them will show you how to construct tables and build the primary!eyforeign !ey relationship.

    =n preparation for building the tables first you will create domains and data elements for the type of data yourtable will store. #or the purpose of learning how to create domains and data elements, you will not use e$istingdomains in the ABAP Dictionary though youll do so a bit later.

    2eturn to the ABAP Dictionary initial screen (E--/. 4hec! theDomain radio button and type a domain name using thistemplate1 Z_$$$$_level. 4lic! the Ceate button.

    Enter the short description, data type and number of characters,as shown here. ave the domain to your lessons pac!age andtransport reIuest.

    4hec! and activate this domain.

    2epeat this process in order to create the following domains. ave and activate each one.

    Page ! of 10

  • 8/19/2019 Abap 017 Tables Data Elements Domains

    5/10

    ABAP Tables, Data Elements and DomainsPrepared by J Kreie

    New Mexico State University 

    Domain "ame Data Type "o. C#a #ot Des%iption

  • 8/19/2019 Abap 017 Tables Data Elements Domains

    6/10

    ABAP Tables, Data Elements and DomainsPrepared by J Kreie

    New Mexico State University 

    4lic! the Do%'mentation button .=f your computer has "icrosoft )ord installed atemplate will open that loo!s similar to thee$ample shown here but it will be in )ord.

    Enter the te$t indicated in the e$ample.

    ave and go bac! with the Ba% button. Activate this data element.

    4reate the remaining data elements shown below. Be sure to add field labels. Hou do not have to add thedocumentation for each element but you can do so, if you wish.

    ave and activate these data elements.

    Data Element "ame #ot Des%iption Domain

  • 8/19/2019 Abap 017 Tables Data Elements Domains

    7/10

    ABAP Tables, Data Elements and DomainsPrepared by J Kreie

    New Mexico State University 

    4reate table

    6ow you will create two tables that use the domains and data elements youve created. =n the 'bFect 6avigatoruse the conte$t menu for the Dictionary 'bFects in your pac!age. elect Ceate * Database Table. (Analternative way to create these tables would be to go straight to the Data Dictionary +E--/. 5se this namingtemplate to name your table1 Z$$$$_Ed'evel. 6ote that there is no underscore after O. The Delivey and"aintenance tab is automatically selected. Enter the short description 8Education Levels9. 5se the value searchfor Delivey Class and select A ("aster and transaction data/. 4hange the Data BoseTable &ie 4aint.setting to Display4aintenan%e Alloed. 

    witch to the -ields tab. Enter the field names shown here andchec! the two columns to theright of the field vl (columns8!ey9 and 8initial value9/. Typeyour data elements names in theData Element column. Hou cansee these names by e$pandingthe list in the left pane.

    4lic! the chec!mar! and themetadata about each dataelement will appear (data type,length, and description./.

    5se the AP menu bar to select1 E5tas * En#an%ement Cate)oy. Houllprobably get a message that you need to select an enhancement categoryproceed by clic!ing the chec!mar!. 4lic! the chec!mar! to accept the defaultsetting1 4an be enhanced.

    ave the table to your transport pac!age. Do not worry if you get a messageabout tables being 8client specific9. The 8client specific9 message occursbecause you should always include a field in any table you build for the AP

    Page 6 of 10

  • 8/19/2019 Abap 017 Tables Data Elements Domains

    8/10

    ABAP Tables, Data Elements and DomainsPrepared by J Kreie

    New Mexico State University 

    client number (called mandt in 3erman/, if the table will be used in a real, wor!ing environment. )e dont needto worry about that for this lesson.

    4lic! the Technical ettings button . 5nder the o)i%al stoa)e paametes heading for Data%lass type or select APP0 for 8master data, transparent tables9. #or i7e%ate)oy type : (: to K-,::: records/. )e do not e$pect this table to have

    many rows of data. ave your changes and use the bac! button to return tothe 4aintain Table screen.

    ave, chec! and activate the table.

    4reate another table called Z$$$$_t'dent. Enter the short description 8tudent =nformation9. 5se the valuesearch for Delivey Class and select A ("aster and transaction data/ and set Data BoseTable &ie 4aint.to Display4aintenan%e Alloed.

    elect the -ields tab and create thefields shown here and for each field typethe appropriate data element youcreated.

    2emember data model these two tables are based on This modelshows that the student table has a foreign !ey field related to theeducation level table. 6ow, youll designate the foreign !ey in thestudent table. 4lic! the T5DE6TL0L field to select it then clic! the

    foreign !ey icon . #or the #ot Te5t enter 8tudents educationlevel.9 #or the C#e% Table, use the value search icon to locate

    and select the EduLevel table you created.

    6e$t, clic! the 8eneate poposal icon . ABAP )or!bench will loo! at the metadata theEduLevel table and retrieve the name of the primary !ey field. 4lic! the chec!mar!.

    et the enhancement category for this table through the AP menu bar1 E5tas * En#an%ement Cate)oy.elect 84an be enhanced9 and clic! the chec!mar!.

    4lic! the Te%#ni%al ettin)s button. et the Data %lass for APPL: ("aster data, transparent tables/. et thei7e %ate)oy for -. ave these settings and return to the table screen.

    ave, chec! and activate this table. Again, dont worry about the 8client specific9 warning.

    =n the ne$t lesson youll create programs to add data to your tables and to display the data.

    Page 9 of 10

  • 8/19/2019 Abap 017 Tables Data Elements Domains

    9/10

    ABAP Tables, Data Elements and DomainsPrepared by J Kreie

    New Mexico State University 

    Pa%ti%e

    4reate two tables based on the following data model. 4reate the necessary domains and data elements anduse these in the tables. The registration table has a date field, which you havent defined before. 5se the DATdata type with a si&e of M.

    Tems to :no

     ABAP Dictionary..................................................................................................................................................... -data element........................................................................................................................................................... Kdomain.................................................................................................................................................................... Kmetadata................................................................................................................................................................. -

    Page ; of 10

  • 8/19/2019 Abap 017 Tables Data Elements Domains

    10/10

    (eeins SQhnhauser, AP Press, K::.

     ABAP 'bFects1 An =ntroduction to Programming AP Applications. >orst Seller and ascha Sruger, AP Press,K::K.