0% found this document useful (0 votes)
14 views26 pages

Chapter 08 - ABAP Dictionary Objects-Views

The document provides an overview of ABAP Dictionary Objects, specifically focusing on Views, which are used to access data from one or more tables without containing data themselves. It explains various relational operations such as Projection, Selection, and Join, and outlines different types of Views including Database View, Projection View, Help View, and Maintenance View. Additionally, it includes examples of how to use Views in ABAP programs.

Uploaded by

Aniruddha_Ghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views26 pages

Chapter 08 - ABAP Dictionary Objects-Views

The document provides an overview of ABAP Dictionary Objects, specifically focusing on Views, which are used to access data from one or more tables without containing data themselves. It explains various relational operations such as Projection, Selection, and Join, and outlines different types of Views including Database View, Projection View, Help View, and Maintenance View. Additionally, it includes examples of how to use Views in ABAP programs.

Uploaded by

Aniruddha_Ghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

IBM Global Services

ABAP Dictionary Objects: Views

ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Objectives

 The participants will be able to:


 Define a View.
 Explain the different Relational Operations.
 Discuss the different types of Views.
 Discuss how to use Views in an ABAP program.

2 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

What is a View?

 Views are used to look into one or more tables.


 A view does not contain data of its own.

3 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

The Most Basic Form of a View

 In its most basic form, a view simply mirrors an entire database table

4 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

The Relational Operations

 We can use views to Join several tables, Project (or choose) certain fields
from one or more tables & Select (or choose) certain records from one or
more tables.

Projection Selection Join


Table 1 Table 2 Table 3 Table 4

View A View C

View B

5 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

The Projection Operation

 The projection operation is used to narrow a view’s focus to certain fields in a


table.

Projection
Table 1

View A

6 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Specifying Projected Fields

Can use any field name if database view,


otherwise must be same name as table field.

7 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

The Selection Operation

 The selection operation is used to narrow a view’s focus to certain records in a


table.

Selection

Table 2

Example:
Staff Level <= 3

View B

8 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Specifying Selection Criteria

Can include unprojected fields

1 2 3 4 5

9 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

The Join Operation

 The join operation is used to combine information from multiple tables into a
single view.
Join
Table 3 Table 4

View C

10 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

The Necessity of the Join Operation

 Database design principles often require related data to be stored in separate


tables. This is called normalising.

Employee

ID Name Salary 1 Salary 2 Salary 3 …

Salary
ID Name Salary

5579 Smith $10,000.00

5579 Smith $11,000.00


Wrong
5579 Smith $12,000.00

5579 Smith $13,000.00


11 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation
IBM Global Services

Understanding the Join Operation

 The join operation essentially reverses the normalising process.


 The result of a join is a view that looks like a table with redundant data.
Employee

ID Name …
Salary

ID Salary Date Effective

5579 $10,000.00 10/1/91

5579 $11,000.00 10/1/92


Right
5579 $12,000.00 10/1/94

5579 $13,000.00 10/1/96


12 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation
IBM Global Services

The Join Operation and Foreign Keys

 Therefore, in order to use the join operation in SAP, you must first ensure that
the appropriate foreign key relationships exist among the tables to be joined.

Join
Primary Secondary
Table 3 Table 4

View C

13 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Specifying Joined Fields


Indicate base tables that data will come from.

Join Conditions

Hit button to see related tables and


automatically generate join conditions.

14 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Types of Views in the ABAP Dictionary

 Database View
 Projection View
 Help View
 Maintenance View

15 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

The Database View

 The database view is the only type of view in SAP that is physically created at
the database level.
Database View

Database
DB
16 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation
IBM Global Services

Demonstration

 Creation of a database view using two related database tables.

17 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Practice

 Creation of a database view using two related database tables.

18 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

The Projection View

 The projection view is a logical view. In this context, the word “logical” means
that the view exists within the ABAP Dictionary but is not recognized by the
underlying database system.

Projection View

View C

19 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Database vs. Projection Views

Projection View Database View

• Can be built over many tables


• Must be built over a single table • Data can be updated if the view is built
• Data can be updated over a single table
• Data updates must use open SQL • Data updates can use open or native SQL
• Updates are less efficient • Updates are more efficient
• Fields in the view must be named the same • Fields in the view can be named differently
as the fields in the underlying table from the fields in the underlying table
• Can’t be buffered • Can be buffered

20 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Other Types of Views

 Help View:
Help views can be used as selection methods for Search Helps.It might be
necessary to create a Help View if you are trying to accomplish an outer join.
 Maintenance View:
These views permit maintenance of base table data. Transactions SM30 and
SE54 are provided for working with maintenance views.

21 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Using a View in Program Code

DATA : WA_YXXEMP_V TYPE YXXEMP_V.

SELECT *
FROM YXXEMP_V INTO WA_YXXEMP_V.

WRITE: / WA_YXXEMP_V-EMP_ID,
WA_YXXEMP_V-LAST_NAME,
WA_YXXEMP_V-FIRST_NAME.

ENDSELECT.

22 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Demonstration

 Select data from the database view created earlier and display selected data in a
report.

23 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Practice

 Select data from the database view created earlier and display selected data in a
report.

24 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Summary

 Views are used to look into one or more tables. A view does not contain data of
its own.
 The projection operation is used to narrow a view’s focus to certain fields
in a table.
 The Selection Operation is used to narrow a view’s focus to certain records
in a table.
 The Join Operation is used to combine information from multiple tables into a
single view.
 Types of Views in the ABAP Dictionary are Database View, Projection View, Help
View & Maintenance View.
 The syntax to reference a view in an ABAP program is the same syntax we use to
reference a table.

25 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Questions

 What is a View ?
 What is a Database view ?
 What is a Projection view ?
 What is a Maintenance view ?
 What is a Help view ?

26 ABAP Dictionary Objects: Views | Dec-2008 © 2005 IBM Corporation

You might also like