Welcome to SAP ABAP Data Dictionary tutorial. This tutorial is part of our free SAP ABAP training and we will have the first look at what is SAP ABAP Data Dictionary and what tools does it offer to ABAP developers. You will learn about object types in data dictionary and the concept of activation.
SAP ABAP Data Dictionary, also called ABAP Dictionary, Data Dictionary, DDIC, is a key architecture concept for understanding functioning of SAP ERP system. Very few IT systems nowadays have similar architecture, so it may be a hurdle for a developer to understand its key features and functions. So, what is SAP ABAP Data Dictionary on its own?
SAP ABAP Data Dictionary is a persistent repository of metadata which is used to define different data objects that are used in SAP business applications. What are these data objects? They can be elementary objects, structural or tabular objects and will be discussed further in this tutorial. SAP ABAP Data Dictionary is called via SE11 transaction code.
There is also SAP ABAP Repository, which is often mixed up by beginners with SAP ABAP Data Dictionary. ABAP Repository, which GUI representation is ABAP workbench (transaction SE80), was reviewed by us in the previous tutorial. SAP ABAP Repository stores programmatic object definitions (e.g. programs, modules) whilst ABAP Data Dictionary stores data definitions (e.g. structures, tables). However, there is a lot of literature in the web where these terms are muddled and used interchangeably.
SAP ABAP Data Dictionary’s key features can be outlines in the following picture.
SAP ABAP Data Dictionary features can easily be distinguished from this scheme:
- Integrity. Data Dictionary is integral and consistent throughout all elements and consumers using it (ABAP Interpreter, Data Modeler and so on).
- Reusability. All elements of SAP infrastructure reuse the same common elements.
- Persistence. Data object in Data Dictionary are saved only once for future use.
As it was stated above, all objects in SAP ABAP Data Dictionary are reusable, and one can create as many tables as he wants based on the same data elements, dozens of data elements based on the same domain and so on. These are also important features of Data Dictionary – redundancy minimization and routine elimination. You don’t need to recreate from scratch the huge table consisting of 100 fields. You just copy the structure from existing table and change only the needed parameters.
Object types in Data Dictionary
Object types which are maintained via SAP ABAP Data Dictionary are shown on the initial ABAP Dictionary screen:
They can be logically differentiated into several main groups:
- Data types
- Database types
- Service types
Data types is the main and biggest group of ABAP Dictionary objects which comprises of:
- Data elements. These are elementary data types which have the same function as ABAP elementary types, however they are available for any repository and data object, unlike ABAP types. Their attributes can be defined on the base of primitive type or using the domain.
- Domains. Domain objects serve for describing data elements properties: data type, data length, value range and text description. They define how data element would look in tables, screens and reports.
- Structures. Structure is a basic and most important type in ABAP which is used literally everywhere. Technically structure is a set of predefined fields that can hold structural data and can describe work areas, table types and finally DB tables.
- Table types. Table types can describe internal tables in ABAP programs. Table types are somewhat similar to structures, because they consist of predefined set of fields, but they have one useful feature: they can define primary and secondary keys, which is very useful for querying.
Database group comprises objects created in the database layer which serve for storing tabular data. Main types here are:
- Database tables. This is the main way of storing business and supplementary data in SAP. Technically, tables in SAP can be divided into transparent ones, pool tables and cluster tables. What are the differences? For now, they are irrelevant to us and we will review only transparent tables here.
- Views. One who is familiar with SQL dialects can easily recall view concept, as it is quite known in many RDBMS. A view is a set of predefined columns which are joined by some key, maybe sorted and maybe grouped. So, in terms of SQL language, view is fields that were connected by JOIN operator.
How are tables defined in a Data Dictionary? Key elements of table definitions in ABAP Dictionary are the following:
- Data elements. They define which type would have correspondent table fields.
- Table fields. They describe structure of business data.
- Primary key. Primary key apply constraint to a table and make possible efficient sorting and querying.
- Foreign keys. Foreign keys are useful for making relations between tables.
- Indexes. Indexes are used to optimize selections from the table.
A good example of reusability is a table type. If one needs several table types which are based on the same structure (e.g. with different keys), it is not necessary to create table types again and again. One just need to copy the needed table type to the new one and change the key fields. Let us show the reusability on the example. As an example, let us create a table type without recreating underlying structure, but with the help of existing one:
1. On first step, we start SAP ABAP Data Dictionary by SE11 transaction and enter the name of the table we want to create.
2. Secondly, we specify table type parameters. As you’ve already guessed, we will create a table type based on the existing standard SAP ECC table MARA. With the built-in Data Dictionary selector, we choose the necessary structure and put it into the Line Type field.
Fields Short text and Line Type, which are highlighted on the screenshot are mandatory for that object type. Other definition parameters which are presented by tabs Attributes, Primary Key and Secondary Key are optional.
After selecting MARA type from the Dictionary, one can notice that the type editor automatically fetches type definition and shows us that it is a structured type. Other options to define table type are: predefined Data Dictionary type and Reference type, which will be discussed later.
3. After entering type specification, we save our new type, which means its definition was recorded to SAP ABAP Data Dictionary database, but still is not usable, because it is inactive.
4. In order to use our table type in developments, we need to activate it by Activate button on the toolbar.
And only after activation it will be fully available to all programmatic and data objects in SAP system.
Congrats! We have created our first Data Dictionary object.
Service types are types that are not directly used for defining business data but rather have a servicing role and help developer to interact with other data objects. Two main service types are:
- Lock objects. Lock objects specify which database tables connected via foreign keys are affected during the shared lock. During creating of lock object two lock function modules are created. We will review lock concept later.
- Search helps. Search helps are supplementary objects constructed to help user to find business objects faster, smoother and more conveniently. It allows searching business objects by custom fields and rules.
Activation of SAP ABAP Data Dictionary Objects
Previously in our example we used term activation, but we did not define it properly. As it was stated, firstly objects are saved in Data Dictionary but for using them they need to be activated. The concept of activation is critical for understanding of SAP ABAP Data Dictionary, and should be discussed in more details.
Logically ABAP execution system can be divided into ABAP Data Storage, where the definitions are kept and ABAP Runtime where they are used. During the execution of any program in runtime ABAP interpreter takes objects not from the storage but rather from ABAP Runtime and that where activation comes into play. When an object is activated its buffered and optimized form is placed into the runtime and preloaded when the program is started. If the object is compound (deep structure or table), it is rebuilt and its subcomponents are reactivated during each activation of the root object. This crucial point should be learned solidly to develop accurate and fast programs. The below picture illustrates this concept.
What this means for a developer from the practical angle? Here is what: one should always remember that changing underlying data type or domain that is used massively throughout the Data Dictionary will affect all the tables and fields it is in. So, it should be done with caution and very accurately. If the tables you are going to change already contain data, the activation can fail, or even when succeeded, can create inconsistencies. Developer should always consider relations of the object being edited to other database objects, for which SAP Where-Used tool is essential (it was discussed in the previous tutorials).
Did you like this tutorial? Have any questions or comments? We would love to hear your feedback in the comments section below. It’d be a big help for us, and hopefully it’s something we can address for you in improvement of our free SAP ABAP tutorials.