Файл: BC430_EN_Col62_FV_Part_A4_-_ABAP_Dictionary.pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 03.04.2021

Просмотров: 2295

Скачиваний: 40

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.
background image

BC430

Lesson: Views

Figure 80: Database Views

A database view is defined in the ABAP Dictionary and automatically created on
the database during activation. Accesses to a database view are passed directly
to the database from the database interface. The database software performs the
data selection.

If the definition of a database view is changed in the ABAP Dictionary, the view
created on the database must be adjusted to this change. Since a view does not
contain any data, this adjustment is made by deleting the old view definition and
creating the view again in the ABAP Dictionary with its new definition.

The maintenance status defines whether you can only read with the view or
whether you can also write with it. If a database view was defined with more than
one table, you can only read with this view.

The data read with a database view can be buffered. View data is buffered
analogously to tables. The technical settings of a database view control whether
the view data may be buffered and how this should be done. The same settings
(buffering types) can be used here as for table buffering. The buffered view data is
invalidated when the data in one of the base tables of the view changes.

2006/Q2

© 2007 SAP AG. All rights reserved.

183


background image

Unit 7: Views and Maintenance Views

BC430

Figure 81: Dynamic attachment of table fields in database views

You can include entire tables in database views. In this case all the fields of the
included table become fields of the view (whereby you can explicitly exclude
certain fields). If new fields are included in the table or existing fields are deleted,
the view is automatically adjusted to this change. A new or deleted field is
therefore automatically included in the view or deleted from it.

If an append structure is added to a table included in a view, the fields added with
the append structure are automatically included in the view.

To include a table in a view, you must enter the character “*” in the field

View field

in the view maintenance, the name of the table to be included in the field

Table

and the character “*” again in the field Field name.

If you do not want to insert a field of the included table in the view, you must enter
a “-” in the field

View field

, the name of the included table in the field

Table

and

the name of the field to be excluded in the field

Field name

.

As of Release 4.6C, fields of the base tables of a database view can be included
in the view without modifications using an append view. This is analogous to
enhancing a table with an append structure. An append view is assigned to

exactly

one

database view. More than one append view can be created for a database view.

184

© 2007 SAP AG. All rights reserved.

2006/Q2


background image

BC430

Lesson: Views

Exercise 11: Views

Exercise Objectives

After completing this exercise, you will be able to:

Create views

Define join conditions

Buffer database views

Business Example

The data existing for an employee is distributed on several tables (corresponding
to the relational data model). For some exercises, however, a complete view on
this data is needed. In this exercise, the corresponding views are implemented
by creating views.

The flight personnel (all pilots and stewards) must be selected when a flight crew
is set up. Not all the data in table ZEMPLOY## may be displayed when this
data is accessed; for example, the employee setting up the teams may not see the
salary of the crew members. The telephone number of the employee's department
should be output in case of questions.

Task:

1.

Create a suitable database view ZEMPFLY## that satisfies the requirements.
The following information about an employee should be displayed:

Client

Airline

Personnel number

First name

Last name

Telephone number of the department

Department code

Note:

The view should permit a view on data in tables ZEMPLOY##

and ZDEPMENT##. The view should display data about
employees (from table ZEMPLOY##) and departments (from table
ZDEPMENT##).

2.

Transfer the fields from the tables in the view.

Continued on next page

2006/Q2

© 2007 SAP AG. All rights reserved.

185


background image

Unit 7: Views and Maintenance Views

BC430

3.

Make sure that only flight personnel can be selected with the view. Define
this restriction via a selection condition.

You probably will have to (frequently) access the data using the view. The
selected data should therefore be buffered in order to increase performance.
Choose

full buffering

as buffering type.

4.

Buffer the view.

186

© 2007 SAP AG. All rights reserved.

2006/Q2


background image

BC430

Lesson: Views

Solution 11: Views

Task:

1.

Create a suitable database view ZEMPFLY## that satisfies the requirements.
The following information about an employee should be displayed:

Client

Airline

Personnel number

First name

Last name

Telephone number of the department

Department code

Note:

The view should permit a view on data in tables ZEMPLOY##

and ZDEPMENT##. The view should display data about
employees (from table ZEMPLOY##) and departments (from table
ZDEPMENT##).

a)

In the initial screen of the ABAP Dictionary, mark object type

View

,

enter the object name

ZEMPFLY##

and choose

Create

.

b)

A dialog box appears in which you should select the view type. Mark

Database view

and choose

Choose

.

c)

Enter a short text in the next screen.

d)

First enter table

ZEMPLOY##

in field

Tables

.

e)

Choose

Relationships

. All the foreign key relationships of table

ZEMPLOY## to other tables are listed. Mark the relationship to table
ZDEPMENT## and choose

Copy

.

The join conditions are copied from the foreign key.

f)

In a different mode, display the foreign key between the two tables and
notice the relationship between the foreign key and the join conditions.

Continued on next page

2006/Q2

© 2007 SAP AG. All rights reserved.

187