Файл: BC430_EN_Col62_FV_Part_A4_-_ABAP_Dictionary.pdf

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

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

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

Добавлен: 03.04.2021

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

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

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

BC430

Lesson: Changes to Tables

Solution 9: Changes to Database Tables

Task 1:

Shorten one field in the ZFLCREW## table.

1.

Reduce the field length to 15 characters.

Note:

Create a new data element ZROLE## and replace the existing

data element with the new one. When you define data element
ZROLE##, do not use a domain. Instead, enter the data type and
length directly when you define the data element. Now activate
the table.

Go to change mode in the maintenance screen for table ZFLCREW##.

a)

Overwrite data element SEMP_ROLE in the

Field type

column with

the name of your data element

ZROLE##

. Save your changes.

b)

Select the name

ZROLE##

. In the next dialog box, confirm that you

want to create the data element.

c)

In the data element maintenance screen, enter a short description.

d)

Select the

Definition

tab page. Choose

Built-in data type

. Enter

CHAR

in the

Data type

field,

15

in the

Length

field, and

0

in the

Decimal

places

field.

e)

On

Field label

tab page, maintain the text for the data element.

f)

Activate the data element.

2.

Display the activation log. The system reminds you that shortening the field
makes it necessary to convert the table ZFLCREW##.

a)

Go back to the table maintenance screen.

b)

Navigate to the database utility with

Utilities

Database Utility

.

c)

Choose

Activate and adjust database

. Confirm this at the confirmation

prompt. The system now converts the table.

Task 2:

Employees with management or maintenance functions have their workplace
at an airport. Record information about how to reach these employees in table
ZEMPLOY##: a telephone number for reaching maintenance employees at the
airport and an office location or where the administrative employees work.

1.

Create an append structure for table ZEMPLOY## containing the following
information:

Continued on next page

2006/Q2

© 2007 SAP AG. All rights reserved.

163


background image

Unit 6: Changes to Tables

BC430

Field

Data Element

ZZAirport

S_AIRPORT

ZZOffice number

S_BUREAUNO

ZZTelephone number

S_TELNO

Note:

The field names in an append structure must lie in the

customer namespace for fields. The field names must therefore
begin with ZZ or YY.

a)

In display mode, go to the maintenance screen for table ZEMPLOY##.

b)

Choose

Goto

Append Structure

.

c)

In the next dialog box, enter the required name for the append structure.
It must satisfy the usual naming conventions. Choose

Continue

.

d)

The system displays the maintenance screen for the append structure.
You maintain the append structure in the same way you would maintain
a structure.

e)

Enter a short text and insert the fields

ZZAirport

,

ZZOffice number

, and

ZZTelephone number

with the specified data elements.

f)

Activate the append structure. Choose

Goto

Activation Log

to

display the activation log.

g)

Table ZEMPLOY## is automatically adjusted when you activate the
append structure. The new fields are appended to the existing fields
on the database.

Task 3:

Create a suitable foreign key for the

Airport

field from the append structure.

1.

Define the foreign key in the maintenance screen of the append structure.

Hint:

The table for all airports is called SAIRPORT. For a complete

definition of the foreign key, you also need to verify a field in the
appended table (ZEMPLOY##).

Continued on next page

164

© 2007 SAP AG. All rights reserved.

2006/Q2


background image

BC430

Lesson: Changes to Tables

From the maintenance screen for the table ZEMPLOY##, choose

Goto

Append Structure

.

a)

Place the cursor on the

Airport

field. Choose the key icon. Copy the

system proposal.

b)

The maintenance screen for the foreign key appears. The check table
and the field assignments are already filled due to the system proposal.
Enter a suitable short description.

Note:

The foreign key cannot be fully specified using just

the append structure since the key of check table SAIRPORT
contains both a client field and an airport code, while the
append structure has no client field. Make sure that when
generating from the proposal, the client field is actually taken
from the appended table.

c)

Choose

Non-key-fields / candidates

as the type of foreign key fields

(since the

Airport

field is not a key field in the table ZEMPLOY##)

and

C

(since not every employee is assigned to an airport) to CN

(since several employees can be assigned to the same airport) as the
cardinality.

d)

Choose

Copy

and then activate the append structure.

2.

Execute the program BC430_CHECK with transaction SE38. The program
checks whether your solutions are correct.

a)

Execute the program

BC430_CHECK

with the transactionSE38.

2006/Q2

© 2007 SAP AG. All rights reserved.

165


background image

Unit 6: Changes to Tables

BC430

166

© 2007 SAP AG. All rights reserved.

2006/Q2


background image

BC430

Lesson: Changes to Tables

Exercise 10: Database Utility (SE14)

Dealing with Problems (Optional)

Exercise Objectives

After completing this exercise, you will be able to:

Deal with errors when converting tables.

Business Example

When existing DB tables are converted, data may be lost or other problems may
occur. In such cases, you should be able to reverse the conversion.

Task:

You should prevent data from getting lost when errors are made in the conversion.

1.

Avoiding loss of data.

Caution: Before you proceed, you must copy the content of the
employee and department tables into corresponding temporary
tables.

2.

Change the domain for the departments from length 4 to length 2 and
activate the domain.

3.

Activate the dependent objects (tables), too.

4.

Display the log.

Note:

Although only warnings are mentioned in the activation

message, you will find error messages highlighted in red in the log
and an instruction telling you that the tables have to be converted.

5.

First convert the departments table using transaction SE14.

6.

Now convert the employees table and check its contents.

7.

If the conversion fails, try to reverse it again.

2006/Q2

© 2007 SAP AG. All rights reserved.

167