SAP ABAP View
What are views in DDIC?
- Views are the data dictionary repository objects in ABAP, which are used to view the data of several tables in one place.
- A view is similar to the database table, but it does not contain any physical data; instead it derives data from different tables and acts like a virtual table (table without any existence). Since it does not physically store any data, and the database only contains the view definition, hence it takes very little space in the database.
- A view can be created by combining the data of single or multiple tables, which are called base tables.
- Before creating a view, we need to specify the structure for the tables and fields that need to be stored in the view. If we make any change in the base tables, then the changes also reflect in the views automatically.
- The views in DDIC help to save time and increase efficiency, as it is a time-consuming process to extract data from each table; for such cases, we can use view in SAP ABAP Dictionary.
- A view can be used to represent a subset of data stored within a table or to join multiple tables into a single virtual table.
- Whenever a view is executed, it displays the data extracted from the multiple tables.
- In order to create a view in DDIC, we need to join the table, and for joining the table, each table must have at least one common key field.
- The below diagram explains the structure of view:
In the above diagram, there are three tables with some fields, using the view, we are joining the tables.
Joins to create the view
Join is a way to connect or link two or more database tables or displaying the data. In ABAP, there are two types of joins:
- Inner Join
- In an inner join, only those records or data will be selected that have some matching key fields.
- The unmatched data will not be selected for the view.
- Outer Join
- In outer join, all the data of the first table will be displayed, and from the other tables, only the matching record will be displayed.
- If there is no matching record in other tables, then the view will show the record with blank values.
Key steps to define a view:
- First, we need to select the base tables to define the view.
- These base tables must be linked together using join conditions.
- Select the required fields of the base tables that need to use by the view.
- Apply some selection conditions to restrict or filter the records in the view.
Types of Views in ABAP
In ABAP DDIC, there are four types of views that differ from each other in a way in which they are implemented and access the data. These are given below:
- Database view
- Projection view
- Help view
- Maintenance view
- If a view is created on one or more tables by combining the fields using inner join, such a view is called a Database view.
- Since this view uses the inner join, it only combines the matching records from the table.
- In this view, we cannot perform any maintenance operation on table data; instead we can just read the data.
- If a view is created on a single table, then it is called as Projection View.
- Using this type of view, we can minimize the fields by projecting only required fields and rest fields will be filtered out.
- This view allows us to read and also maintain the data.
- The help view is created on two or more than two tables, specifically for the "Search-helps" in DDIC, and we cannot execute it directly.
- It combines the data by using an outer join
- It allows us only to read the data, and we cannot maintain the data in this view.
- It can be used as a selection method in search helps.
- The maintenance view is created on two or more tables by using the outer join concept in DDIC.
- It allows us to maintain and read the data of the table.
- This view is suitable for the custom tables (z or y) only and should not be used with the Standard SAP tables, as it may create the inconsistency problem while changing the record.
- It allows us to maintain the data of several tables for one application at a time.
Note: The database view uses the inner join concept to link the tables, and other views use the outer join concept.