7. Data Elements & Domains z_phonef Label: fax number z_phonew Label: work number z_phoneh Label: home number zphone type: char len: 12 phone_w phone_f phone_h Customer Table Data Domain fields Elements
The ABAP Dictionary The ABAP Dictionary contains the definition of data objects that can be used in all components of the SAP. Typically you find the definitions of tables in the Dictionary . Tables in the ABAP Dictionary are usually defined as transparent tables. This means the table definition in the dictionary has a one-to-one relationship with a table in the database. In other words, for each transparent table definition in the Dictionary there is one associated table in the database. The database table has the same name, the same number of fields, and the fields have the same names as the Dictionary table definition. Therefore when looking at the definition of a table in the ABAP Dictionary , it might seem like you are looking at the database table itself - hence the term transparent table .
The ABAP Dictionary How can the definition of a table in the Dictionary be displayed? ==> drill down on table name in tables or select statement of your program. ==> Select ABAP Dictionary in the Development folder on the Easy Access screen . ==> use the object navigator .
The ABAP Dictionary In the upper part of the screen, you see the short description of the table . The lower part of the screen displays all the table fields. The left column contains the name of each field, with the following field attributes displayed in other columns: Key: Box is checked if the field is a key field for the database table (some key fields are combined to form a table key ; the table key is the combination of key fields . The values in the key fields allow the system to uniquely identify all data records). Data Element : Name of the field’s data element . Data Type : The field’s data type (determined by the domain of the data element) . Length : The field’s length (determined by the domain of the data element) . Check table : A referenced table with a foreign key relationship (used to ensure data integrity/consistency) . Short text : Description of field (determined by the data element) . What is a DATA ELEMENT?
The Data Dictionary Tables are made up of rows containing one or more fields. When a field is defined its data type is determined by reference to a data element . A data element stores semantic properties - field label and online documentation (F1 help) but also references a domain. A domain contains technical properties - data type/length. Domains form the basic foundation for field descriptions. A domain describes the technical structure of a field, i.e. its data type and size. Data elements build on the domains and inherit the properties of the underlying domain. They contain a reference to a domain, to define the technical attributes, and they supplement this with descriptive documentation. Data elements and domains are reusable. So the ABAP Dictionary contains the platform-independent description of the relevant database table. The database table has the same name as the transparent table in the ABAP Dictionary . The fields, too, have the same names in both the database and in the ABAP Dictionary .
The Data Dictionary Example: Assume you need to design a customer information table called zcust , that must contain work, fax and home phone numbers. To create a field, you usually start by creating a domain for it. In this case you might create a generic telephone number domain, name it zphone and give it a data type of CHAR and a length of 12. This domain could now be used in setting up specific types of telephone numbers such as fax & home numbers. After creating the domain to hold the purely technical description of a field, you can then create a data element to hold the descriptive attributes of the field. In this example you would create three data elements, one each for the home , work and fax phone numbers. In each data element, you would enter field labels describing the type of phone number you will store with it, and the F1 help for the end-user. Having created the data elements, you can now create the table. You could create 3 phone number fields in the table (home, work, fax) and assign the corresponding data element to each field. This gives the field descriptive information from the data element and technical information from the domain it references. When the field is used on a screen, it obtains a label and F1 help documentation from the data element, and its length and data type from the domain linked to data element. Data elements and domains exist in the DD independently of the actual table, so that they can be used in several tables. What are the advantages of using data elements and domains in setting up DD table definitions ? (Re-use and consistency, efficiency ==> explain via e.g. of setting up a supplier information table) Go Back to Slide 3 again and refer to “ drill-down ” to get data element definition etc.
This model is provided by SAP for ABAP training and development Note the use of common fields (carrid, connid, fldate) and how the use of data elements and domains promotes consistency and efficiency.