A Brief Introduction To ABAP Data Dictionary by Richa Solanki Medium
A Brief Introduction To ABAP Data Dictionary by Richa Solanki Medium
Listen Share
In the previous article on SAP ABAP, we studied the fundamentals of SAP ABAP.
With my second blog series, I am trying to put together the most crucial term,
called the Data Dictionary in SAP ABAP.
Anything you see in SE11, including tables, data elements, domains, search helps,
views, structures, table types, lock objects are all DDIC objects. Below is the
screenshot of SE11.
Database tables: Database tables are made up of rows and columns. Database
tables are the collection of fields that have technical attributes as well as the
semantic description. The custom tables (by user) should start with the
naming convention as ‘Z’ or ‘Y.’ All the standard tables (by SAP) start with
other names except Z or Y.
View: A view is a virtual table, which does not have any physical existence. It
is created by combining the data of one or more tables. A view does not
occupy any storage space.
Table type: A table type is a global reusable object, ie, we declare in SE11
Tcode, which is used to define the structures and functional attributes of an
internal table in ABAP. To learn more about the internal table, navigate to
‘Part 3’.
Type Group: To encapsulate similar type pools in one group, we make type
group. The inbuilt type pools provided by SAP are SLIS, SAP.
Domain: Domain describes the technical attributes such as data types and
lengths of a table field.
Data element: Data element in sap ABAP gives the semantic description of
fields such as field labels and documentation. It describes how the field can
be displayed to the end-user.
Search Help: To enable the list of entries for one field or many fields, we use
the search help option. The function key for search help is F4.
Lock Objects: To control the parallel access for the same data by multiple
users, we make use of the lock objects. Lock objects in the data dictionary
(DDIC) start with ‘E.’
Table vs Structure
While declaring fields in the database table, all the primary keys should come
together in the beginning.
NOTE: Maximum key fields should be 16. Total fields in a table can be 294.
SFLIGHT — Flight
1. Transparent tables
2. Pool tables
3. Cluster tables
Pool tables: It has a many-to-one relationship. Many pool tables are clubbed and
stored in a single table in a database. This type of table is used to store control
data.
Cluster tables: It has a many-to-one relationship. Many cluster tables are clubbed
and stored in a single table in a database.
Once the screen gets loaded, select the ‘database table’ radio button and
provide the name for the table. Remember, the naming convention should
start from ‘Z’ or ‘Y’ to indicate its the custom table.
Further, click on the Create button and enter the short description. Choose
the delivery class as ‘A.’ Also, choose the ‘Display/Maintenance allowed’ from
the dropdown.
The delivery class in SAP ABAP determines whether the data of the table can
be transported or not. Types of the delivery class are as follows:
5. E -Control table
7. W -System table
NOTE: We usually use the delivery class as ‘A’ since it contains both master ad
transactional data. Master data is needed alot but changes seldomly. Transactional
data is also used alot and changes frequently.
Navigate to the ‘Fields’ tab to enter the fields of the table. Now there are two
options to provide data types to each field, mainly by data element or by
predefined data type.
Field: List all the fields which are required for the table. Primary keys should
come at the start.
Key: Tick the checkbox for the fields which are primary.
Data element: All the data elements will start with ‘Z’ as the naming
convention.
Further, double click on every data element to provide a short description
along with the domain name. The naming convention of the domain should
start from ‘Z.’
As discussed, the data element in sap ABAP provides the semantic description
of the fields. Hence one should always provide the field label. Hence navigate
to the field label tab and provide 4 types of lengths:
1. Short
2. Medium
3. Long
4. Heading
Navigate again to the data type tab and double click on the domain which you
provided. Provide a short description and data type of the particular field.
The domain also provides the option of the value range, which acts as the
dropdown list for the particular field. Provide the ranges and click on save
and hit the activate button.
Also, save and activate the data element. Repeat this procedure for every
individual field by providing data elements, field labels, domains.
Now click on the ‘Technical settings’ button or hit ‘Ctrl+shift+F9’. Here, we
provide the data class and size category.
Data class: This is the physical area in the database where all the data of the
table are stored. With the help of the data class, SAP segregates and organizes
the tables according to their types of data. It keeps all the master data
together, all transaction data together, all user data, and all organization data
together. This increases system performance. Following are the types of data
class:
3. APPL2 -Organization data (Customizing data that is defined when the system
is installed and seldomly changed.
Size category: This determines the expected size required for the table. The
default size for type ‘0’ is 8 KB.
Save, activate, and hit on the ‘No’ button.
We are done with the creation of a table. Now to create entries in a table,
navigate to Utilities > Table contents > Create entires.
Fill the entires one by one and hit the save button.
Once all the entries are created, go back and hit the Contents button
(Ctrl+shift+F10) and click on the execute icon (F8).
OUTPUT:
Database views: This type of view creates a join between two or more tables
based on common fields. Moreover, Database Views are only meant for
reading purposes.
Projection views: This type of view does not join any tables. It simply uses one
table and shows the output to the user. This view is meant for both reading
and writing purposes.
Maintenance views: This view is the same as the Database view. Maintenance
views generate the screen runtime for maintaining and displaying records.
Help views: This is a special view for use in search helps (F4).
Navigate to SE11 transaction. Choose the radio button which says ‘View.’ Give
a suitable name for the same. Ensure the naming convention should start
from ‘Z’ or ‘Y.’ Once done, click on the create button.
You will get the screen which has various types of views. Here we will go for
the ‘Database View.’
Give a short description. Next, provide the name of the master table (KNA1),
click on the relationship button, and select the dependent table (VBAK). Once
we select two tables, we get the join condition automatically. Here the join
condition is on fields ‘Mandt’ and ‘Kunnr.’
NOTE: Since database view enables joins of 2 tables, hence we have an option of
relationship button.
Further, navigate to View Fields tab and mention the fields which you want to
display to the user from both the tables. In our example, the two tables are
KNA1 and VBAK.
NOTE: The above screenshot will throw an error since there is a blank space in the
view field of customer ID. Hence ensure it write as ‘customer_ID’.
Save and hit the activate icon (Ctrl +F3). Navigate to the Utilities tab located on
the menu bar and click on the contents option. The below screen gets
displayed.
The below output displays the entries for the fields ‘Customer’ and ‘Name.’
There is no entry for the fields ‘City’ and ‘Sales document.’
NOTE: There is no word as a ‘relationship’ since the projection view is meant for only
one table.
Further, click on the maintenance view and ensure the selected radio-button
is read and change.
Save and activate and hit the utilities from the menu bar to view the contents.
Select the suitable checkbox and click on the ‘copy’ button. Save and hit the
activate icon.
Further, go to the Utilities tab > table maintenance generator.
Click on the ‘create’ icon, which is located to the extreme left besides ‘Find
SCR. Number’
Further, go back and select utilities > contents. The last step is to select the
‘maintain’ button.
Lastly, maintain the entries.
Once the screen gets loaded, we have three options to go for. We will select
the ‘Structure’ radio button.
Provide a short description and type the fields which you want to use in the
structure. Here I have used built-in data types for the fields ‘EMP_NAME’,
‘EMP_NO,’ and ‘LOCATION.’
Save and hit the activate icon (Ctrl +F3).
Now, we will consume this structure in our report. So navigate to SE38 and
copy-paste the below snippet.
LOGIC:
*& — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
— — -*
*& Report ZRDS_STRUCTURE
*& — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
— — -*
*&
*& — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
— — -*
REPORT ZRDS_STRUCTURE.
DATA : EMPLOYEE TYPE ZRDS_STRUCTURE.
EMPLOYEE-EMP_NAME = ‘SAP.’
EMPLOYEE-EMP_NO = ‘12346879’.
EMPLOYEE-LOCATION = ‘MUMBAI.’
WRITE:/ EMPLOYEE-EMP_NAME, / EMPLOYEE-EMP_NO, / EMPLOYEE-LOCATION.
OUTPUT:
Steps to create a global nested structure
Let’s use the existing structure. Here, I have added the field ‘EMP_ADDRESS’.
Double click on the data element (ZRDS_ADDRESS) and add the fields. Save,
check, and activate.
Once adding all the fields of nested structures, you will be able to see the
icon.
Now, we will consume this structure in our report. So navigate to SE38 and
copy-paste the below snippet.
LOGIC:
*& — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
— — -*
*& Report ZRDS_STRUCTURE_NESTED
*& — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
— — -*
*&
*& — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
— — -*
REPORT ZRDS_STRUCTURE_NESTED.
DATA : EMPLOYEE TYPE ZRDS_STRUCTURE.
EMPLOYEE-EMP_ADDRESS-EMP_CITY = ‘MUMBAI’.
WRITE: EMPLOYEE-EMP_ADDRESS-EMP_CITY.
OUTPUT:
Steps to create SAP ABAP Type Groups
In a type group, we can declare all the local data types and constants that can be
consumed in different programs.
Rather than writing local types, one prefers making the type groups that
consolidate all local types.
Enter the short description. Save and copy-paste the below code snippet.
LOGIC:
TYPE-POOL ZRDS1.
TYPES : BEGIN OF ZRDS1_KNA1,
KUNNR TYPE KNA1-KUNNR,
LAND1 TYPE KNA1-LAND1,
NAME1 TYPE KNA1-NAME1,
END OF ZRDS1_KNA1.
TYPES: BEGIN OF ZRDS1_VBAK,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
END OF ZRDS1_VBAK.
LOGIC:
*& — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
— — -*
*& Report ZRDS_TYPE_POOL
*& — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
— — -*
*&
*& — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
— — -*
REPORT zrds_type_pool.
TYPE-POOLS : zrds1.
DATA : it_kna1 TYPE TABLE OF zrds1_kna1,
wa_kna1 TYPE zrds1_kna1.
SELECT kunnr land1 name1 FROM kna1 INTO TABLE it_kna1 UP TO 5
ROWS.
LOOP AT it_kna1 INTO wa_kna1.
WRITE: / wa_kna1-kunnr, wa_kna1-land1, wa_kna1-name1.
ENDLOOP.
OUTPUT:
SAP ABAP Search help
There are two types of search helps:
1. Elementary search help: Based on one single field, we can populate the data
for the rest of the fields if the table.
2. Collective search help: This collects several elementary search helps. Hence,
Collective search help provides an alternative search path for a particular
field.
Give a short description. Enter the table name in the selection method. Here I
have used the table (ZRDS_EMPLOYEE), which was created earlier. Further,
change the option of dialog type to ‘display values immediately.’ Entering the
hotkey is optional.
Next, enter the fields on which we want to populate the search help (Hit F4 to
get the list of fields). Here I have used all fields of the table
(ZRDS_EMPLOYEE).
Select the field on which you want a search help. Here, I have done search
help on EMPLOYEE_ID. Hit the search button. Enter the Search help name
which you created prior.
Hit the ‘Create Proposal’ button and click on the ‘Copy’ button, which is
located at the extreme bottom.
Once the search help is implemented successfully, the below message will
popup.
For Collective Search Help, we need to create more than 1 elementary search
help. Here I have already created two Elementary search helps.
To start with, navigate to Included Search helps tab. Mention all the
Elementary search helps.
Save and hit the activate icon and execute it the same way as elementary
search help.
NOTE: At one time, only a single search help can be applied to a single field.
NOTE: When lock objects are enabled, 2 function gets created namely, ENQUEUE and
DEQUEUE.
2. Write lock: Only one user can write while the rest can read.
Further, provide a short description and enter the table name. Here I have
used the table (ZRDS_EMPLOYEE), which was created prior. Apply the lock
mode as write.
Navigate to the ‘Lock parameter’ tab, and you will get the display of only
primary keys.
Further, save and press F3. Once the lock objects are activated, by default, two
function modules are created.
To watch the function modules, click on the GoTo tab from the menu bar and
click on lock modules.
NOTE: To release the lock, navigate to transaction SM12.
I hope the above explanation gives the individual a brief knowledge of the Data
Dictionary in SAP ABAP.