0% found this document useful (0 votes)
3 views

ViewsPost2 (1)

The document provides an overview of views in SAP ABAP, detailing their role in the ABAP data dictionary as logical data sets derived from one or more tables. It explains the types of views, including database views, projection views, help views, and maintenance views, along with their creation processes and functionalities. Additionally, it discusses the importance of joins in creating views and the efficiency benefits they offer in data management.

Uploaded by

naveen061288
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

ViewsPost2 (1)

The document provides an overview of views in SAP ABAP, detailing their role in the ABAP data dictionary as logical data sets derived from one or more tables. It explains the types of views, including database views, projection views, help views, and maintenance views, along with their creation processes and functionalities. Additionally, it discusses the importance of joins in creating views and the efficiency benefits they offer in data management.

Uploaded by

naveen061288
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Views in SAP ABAP

Contributed by
Sana Shaikh
Under the guidance of TagSkills

.SAP ABAP data dictionary is a central and structured source of data for
development of objects. It is a database independent DDL (Data Definition
Language) and mainly deals with create, edit, drop the database tables. In data
dictionary you can define and maintain objects which are related to database. The
ABAP data dictionary can be easily integrated with the ABAP workbench, so all
the components of workbench can be easily access the definitions stored in the
ABAP dictionary.
T-code for ABAP dictionary is se-11.
The important objects of data dictionary are as follows.

1. Database tables
2. Domains
3. Data elements
4. Views
5. Search helps
6. Lock Objects

Views and Type of View

o ABAP views in data dictionary are logical data sets which contain data
extracted on one or more tables as a single entity. A view on one or
more tables refer as the data from a view is not stored in physically
manner as the data being derived from one or more tables. It is a time
consuming process to extract the data from several tables, in order to
simplify the process and increase efficiency of code, you can define a
view

6360959192 www.tagskills.com [email protected]


o Views are the data dictionary repository objects in ABAP, which are
used to view the data of several tables in one place.
o 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.
o A view can be created by combining the data of single or multiple tables,
which are called base tables.
o 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.
o 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.
o 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.
o Whenever a view is executed, it displays the data extracted from the
multiple tables.
o 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.

6360959192 www.tagskills.com [email protected]


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:

o Inner Join
o In an inner join, only those records or data will be selected that have
some matching key fields.
o The unmatched data will not be selected for the view.
o Outer Join
o 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.
o If there is no matching record in other tables, then the view will show
the record with blank values.

6360959192 www.tagskills.com [email protected]


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:

1. Database view
2. Projection view
3. Help view
4. Maintenance view

Database Views:

o 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.
o Since this view uses the inner join, it only combines the matching records
from the table.
o In this view, we cannot perform any maintenance operation on table data;
instead we can just read the data.

Projection Views:

o If a view is created on a single table, then it is called as Projection View.


o Using this type of view, we can minimize the fields by projecting only
required fields and rest fields will be filtered out.
o This view allows us to read and also maintain the data.

Help Views:

o 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.
o It combines the data by using an outer join

6360959192 www.tagskills.com [email protected]


o It allows us only to read the data, and we cannot maintain the data in
this view.
o It can be used as a selection method in search helps.

Maintenance Views

o The maintenance view is created on two or more tables by using the outer
join concept in DDIC.
o It allows us to maintain and read the data of the table.
o 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.
o It allows us to maintain the data of several tables for one application at a
time.

Database Views in ABAP

o 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.
o The database view gives an application-specific view to data of an
application object, which is distributed among different tables.
o In this view, we cannot perform any maintenance operation on table data;
instead we can just read the data.
o The database views are specified within the ABAP dictionary, and a
database view is automatically created in the underlying database when we
activate the view.
o We can also view the data of database views in an ABAP program with the
help of the database interface. One can access the data in the program
using OPEN SQL and NATIVE SQL.
o This view can include data from some fields of a table and also the entire
table.

6360959192 www.tagskills.com [email protected]


The below diagram explains the working of the ABAP database view

Creating Database view

Below are the steps used to create the database view in SAP ABAP:

Step-1: Open the data dictionary initial screen by navigating the menu path or
entering the transaction code SE11 in the command field.

Step-2: Click the radio button in front of View option, and give a name to the
view then click the Create button given on the screen.

6360959192 www.tagskills.com [email protected]


Step-4: A pop-up window will appear with all the views, from where select the
"Database view" and click on the Copy button.

6360959192 www.tagskills.com [email protected]


Step-5: A view maintains screen appears that contains multiple tabs, where
first provide the description in the field "Short description." Consider the
below image:

In the above screen, first, we will select the Table/Join Conditions tab and will
provide the table names (base tables) that we want to link. In our example, we
will take two SAP standard tables that are MARA and MARC. After entering
the table name, we need to click on the Relationships button. Consider the below
image:

6360959192 www.tagskills.com [email protected]


Step:7- When we click on the Relationships button, all the tables with the foreign
key relationship with the base table (MARA) will be displayed. Consider the
below image:

6360959192 www.tagskills.com [email protected]


As another table, we have selected MARC (SAP standard table), and clicked on
the Copy button, given at the bottom of the screen.

Step-8: Once we will select the MARC table, all the join conditions field names
will be filled automatically. Consider the below image:

6360959192 www.tagskills.com [email protected]


Step-9: Now, we will move to the next tab, which is View fields, to select the
fields of both tables that we want to display. Consider the below image:

Step-10: To select the fields of each table, we need to click on the Table
fields button given on the screen (See the above image). It will open a new pop
window with both table names (MARA and MARC). We will select one table at
a time and will select the required fields of each table.

Step-11: Once we click on the Choose button given at the bottom of the screen,
it will open all the fields of the selected table from where we can select the
required fields. Consider the below image:

6360959192 www.tagskills.com [email protected]


After selecting the fields, click on the Copy button. Similarly, we will choose the
fields of another table (MARC).

Step-12: After selecting all the required fields of both tables, save the view as a
local object and activate the view (CTRL+F3) or by clicking on the
activate button. Consider the below image:

6360959192 www.tagskills.com [email protected]


Step-13: The activation window will open, select the View, and click to the
Green tick.

Step-14: Now, we can display the records that we have selected using the
database view. For this, click on the Content (CTRL+SHIFT+F10) option given
at the screen. Once we click on the content option, it will open the selection screen
as given in the below image:

6360959192 www.tagskills.com [email protected]


In the above, we can see all the fields of the table are displayed that we have
selected from both the table. We can either fill the details in the field for the
particular record or can view all the records using the execute button given at the
above image. It will display all the records, consider the below image:

ABAP Projection View


o ABAP Projection views are special views used to hide some fields of a
database table and display only the required or selected fields. Hence,
using this type of view, we can minimize the fields by projecting only
required fields and rest fields will be filtered out.
o This view allows us to read and also maintain the needed data.
o The projection view is created on a single table only, and we cannot
specify any selection/join conditions for this view.
o With the projection view, apart from the transparent database table, we can
also access the pooled tables or cluster tables.

Let's consider an example to understand the use of the projection view. Suppose
we have Students Details table, which contains records such as Student Name
and Roll number, Student address, Student fees, etc. We only want to share
student name and roll number with some companies. In this case, we will use the
projections view of the Student Details table. Hence, if there is a huge amount of
data, but we only want to display the relevant data field, we can choose the
projection view as the perfect option.

The below diagram explains the projection view for a table:

6360959192 www.tagskills.com [email protected]


As shown in the above diagram, only the selected fields of the table are displayed
by the projection views.

Creating Projection Views in ABAP:


o Step-1: Open the ABAP dictionary initial screen by navigating the menu
path or entering the transaction code SE11 in the command field.
o Step-2: Click the radio button in front of the View Give a name to the
view, and click on the Create button, given on the screen. (The name of
the view should be started with z).

6360959192 www.tagskills.com [email protected]


o

6360959192 www.tagskills.com [email protected]


o Step-3: A pop-up window will appear with all the views, from where
select the "Projection view," and click on the Copy button.

o
Dictionary: Maintain Screen Appears, consider the below image:

6360959192 www.tagskills.com [email protected]


o

o Step-4: Here, we have provided the short text for an explanation of view
in the "Short Description" field, and entered the table name
"ZEMPLOYEE"(we have created in the table creation)that we are going to
use, in the Base Table Consider the above image. After entering the
details, we need to save (CTRL+S) it as the local object or within a
package. We are saving it as a local object.
o Step-6: Click on Table fields button, and select the required fields that you
want to display in the output. Click the Copy button, and all the selected

6360959192 www.tagskills.com [email protected]


fields will be displayed on the maintenance screen, as in the given
image:

Here, we are choosing the EMPID and FULLNAME fields from the table. These
fields will appear under the Field Name option.

6360959192 www.tagskills.com [email protected]


o Step- 8: Now, save the view, check for any inconsistency,
and Activate the view using the symbol.

6360959192 www.tagskills.com [email protected]


o Step-9: Click on the Utilities -> Contents, and execute, and you will
get the Selection screen. The output data will be displayed at your
screen. Consider the below output image:
o

As we can see in the above output image, only two fields are displaying here that
we have selected in the table.

o We can either enter the details or can click on the execute or F8 given on
the above screen for displaying all the records of the selected field.
Consider the below image:

6360959192 www.tagskills.com [email protected]


o

Advantages of ABAP Projections View


o Using the projection view, we can display only the required fields and mask
other fields.
o It helps to limit the complete data access of a table from an unauthorized
user.
o Data access and the view from the projection view is faster than other
views.
o It also improves the system's performance, as we minimize the fields by
masking in this view.

ABAP Help Views


o The help views are created on two or more tables, specifically for the
"Search-helps" object in DDIC. It means they are used to provide the input
helps(F4) option for different fields in ABAP.
o When going to search help, views with outer join act as the selection
methods and these methods can be either a table or a view, which specifies
that data can be selected from a view or table. For such purpose, we need
to create the help views in ABAP.
o It combines the data by using an outer join concept.

6360959192 www.tagskills.com [email protected]


o Since it is specially designed for the search help option, we cannot
directly execute the data.
o It allows us to only read the data; we cannot maintain the data in this view.

Note: A table can only be used as a selection method using the help view if
we use the outer join to retrieve the data from the database.

The ABAP help view can be understood using the below diagram.

Creating the Help view in ABAP

To create the help view, follow the below steps:

o Step-1: Open the data dictionary initial screen by navigating the menu path
or entering the transaction code SE11 in the command field.
o Step-2: Click the radio button in front of the View Give a name to the
view, and click on the Create button, given on the screen.

6360959192 www.tagskills.com [email protected]


o

o Step-3: A pop-up window will appear with all the views, from where select
the "HELP view," and click on the Copy

The Dictionary: Maintain View Screen Appears.


o Step-4: Provide the short text for an explanation of view in the "Short
Description" field. E.g., Help view for a test or Creating a Help view.
o Step: 5: Provide the name of the primary table. We are giving the table
name as zstudent_data in the primary table for view under

6360959192 www.tagskills.com [email protected]


the Table column in the Table/Join Condition.

o Step: 6: Place the cursor on the primary table name and press
the Relationship A screen will appear, select the checkbox in front of the
primary table's name, and click on the copy button. In our case, the
secondary table is zstudent_sub, so it is inserted here.

6360959192 www.tagskills.com [email protected]


o

If needed, we can add more tables in the help view, but the other tables must be
linked to each other with the foreign key relationship.

6360959192 www.tagskills.com [email protected]


o Step: 6 Now, we will select the required fields by choosing
the View field tab.

o Step: 8 Select the Table Fields button, and a list of tables contained in this
view is displayed, as shown in the above diagram. From here, we can select
any table, and then need to click on the Choose. All the selected fields will

6360959192 www.tagskills.com [email protected]


be displayed here. Consider the below image:

o Step: 9 Select the Maint. Status tab and set the read-only radio button
under the Access group

6360959192 www.tagskills.com [email protected]


o Click on the Save(CTRL+S) and Activate it by clicking on . Once
it is activated, we can use the help view as the selection method for
Search Help.

Deleting the view in ABAP

We can delete the help view if we don't need it further. To delete the view,
perform the below steps:

o Open the ABAP dictionary initial screen, and choose the view radio
button.
o Enter the name of the view that needs to be deleted.
o Choose the where-used list (), and check for those tables, where the view
is currently being used.
o Select the Delete icon to the view. A box will prompt out to confirm the
deletion.
o Click to yes, to confirm the deletion of the view.
o Once you confirm it, the view will be deleted from the system.

How to choose the Views for the table?


o To read only the data of several tables with inner joins condition, choose
the database view.
o To read data and maintain the data for a single table, choose the projection
o To read only data of several tables with outer join conditions, choose
the help It can also be used for the Input help option.
o If a view is required with outer join, and which allows you to read and
maintain the data, choose the maintenance review.

ABAP Maintenance View


o The maintenance view is created on two or more tables, which is used to
maintain the data of several tables altogether. It helps us to maintain the
complex application objects easily.
o It can combine several tables in a single unit, but the tables must have a
foreign key relationship.
o It allows us to maintain and read the data of the table.
o The data present on several tables create a logical unit that acts as an
application object for the user. With the help of a maintenance view, we

6360959192 www.tagskills.com [email protected]


can display, modify, and maintain the data of such application
objects at once.
o In the maintenance view, all tables must be linked together with the foreign
key, which means the join condition must be derived from the foreign key
always.
o There is always a maintenance status associated with each maintenance
view, which specifies the operations that can be performed on the
associated table.
o The below diagram explains the relationship between an application object,
maintenance view, and the underlying database:

As we can see in the above diagram, the fields F2 and F4 of table 1 and table 2
are linked with the foreign key. Similarly, the fields F5 and F6 of table 2 and table
3 are connected with the foreign key. The maintenance view is implemented on
these three tables and extracting data from F1, F2, F3, F5, and F8 fields.

Creating Maintenance View in ABAP:


o Step-1: Open the data dictionary initial screen by navigating the menu path
or entering the transaction code SE11 in the command field.

6360959192 www.tagskills.com [email protected]


o Step-2: Click the radio button in front of the View Give a name to the
view, and click on the Create button, given on the screen.

o Step-3: A pop-up window will appear with all the views, from where select
the "Maintenance view," and click on the Copy

6360959192 www.tagskills.com [email protected]


The Dictionary: Maintain View Screen Appears

o Step-4: Provide the short text for an explanation of view in the "Short
Description" field. E.g., Creating a maintenance view for
test or Maintenance view example.
o Step- 5: Click on the Table/Join Conditions tab, provide the name of the
primary table for view under the Table column.

6360959192 www.tagskills.com [email protected]


o

o Step-6: Place the cursor on the name of the primary table name and click
on the Relationships
o Step- 7: Tick on the checkbox in front of the table name.

6360959192 www.tagskills.com [email protected]


o

o Step-8: Click on the copy button, and the secondary table will be selected.
o Step-9: Go to the selection conditions tab and provide the conditions. (If
required). Here we are not providing any selection condition.
o Step-10: Go to the View fields tab, click on the Table Fields button to
select the field from each table(primary and secondary).

6360959192 www.tagskills.com [email protected]


o

Repeat the process for the secondary table (ZSTUDENT) also, and all the selected
fields will be displayed under the view field column.

o Step-11: Go to the Maint. Status tab and select the appropriate radio
button. Select the other fields, as shown in the below image:

6360959192 www.tagskills.com [email protected]


o

o Step-12: Go to the Utilities> Table Maintenance Generator, as shown


in the below diagram.

6360959192 www.tagskills.com [email protected]


o Fill the details as shown by the arrow, and save it.
o

o Step-13: Click on Save, Save the view as the local object or under a
package. Here we will save it as a local object. Check for any inconsistency
and Activate the view.

6360959192 www.tagskills.com [email protected]


o Step-14: Now select utilities> Contents. A new screen will appear,
which allows you to read, maintain, and write the data.
o

Here we are changing the Name ANDRICK to ARMAN, which has changed
successfully. Consider the below image:

6360959192 www.tagskills.com [email protected]


Advantages of Maintenance view:
o With the help of a maintenance view, we can extract the required data from
several tables, which is faster than selecting data from an individual table.
o It saves time by maintaining several tables at once, as maintaining each
table separately is time taking process.

6360959192 www.tagskills.com [email protected]


TagSkills
Disclaimer -
© Copyright TagSkills. The copyright in this work is vested in TagSkills.
Please note and abide by copyright laws. This presentation is for
educational purposes only, all logos, photos, and information, etc
used in this Presentation is the property of TagSkills. SAP is a
registered trademark of SAP AG in Germany and many other
countries. We are NOT ASSOCIATED with SAP.

6360959192 www.tagskills.com [email protected]

You might also like