Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
BC430_EN_Col62_FV_Part_A4_-_ABAP_Dictionary.pdf
Скачиваний:
204
Добавлен:
21.05.2015
Размер:
21.37 Mб
Скачать

BC430

Lesson: Maintenance Views

Exercise 12: Maintenance Views

Exercise Objectives

After completing this exercise, you will be able to:

Create simple and complex maintenance views.

Business Example

You should create simple views database tables to generate test data quickly in your project.

Task 1:

Create a maintenance view with the name ZPARTNER##, with which you can easily maintain new business partners.

Note: The business partners are entered in table SBUSPART. A business partner can be either a flight customer or a travel agency. If it is a travel agency, there will be a corresponding entry in table STRAVELAG.

The view should also permit you to maintain tables SBUSPART and STRAVELAG at one time. Include all the necessary fields of the tables in the view.

You want to maintain the data in tables SBUSPART and STRAVELAG together in the maintenance view. If you wanted to enter a new partner directly, you would first have to enter it in table SBUSPART. Only then could you enter the corresponding data in table STRAVELAG (because of the existing foreign key check between SBUSPART and STRAVELAG).

1.Generate the maintenance interface. Use the following parameters:

Function group

ZZBC430##

Authorization group

SUNI

Maintenance type

one-step

Overview screen

100

2.Include the fields of both tables in the view.

3.Generate a maintenace interface for the view.

4.Then maintain the data of a new travel agency using the enhanced table maintenance. Choose System → Services → Table maintenance → Enhance. Tab.maint..

Continued on next page

2006/Q2

© 2007 SAP AG. All rights reserved.

199

Unit 7: Views and Maintenance Views

BC430

Task 2:

Bundle maintenance view in a view cluster.

Note: You want to serve several maintenance views of dependent tables on one single transaction screen. To do this, create a complex maintenance view over several customer tables. In this exercise, use the table from the flight data model again. You will copy these tables including their entire content on the customer namespace.

1.First of all copy the tables SCARR, SPFLI and SFLIGHT into the customer namespace with attached monitor number (ZCARR##, ZPFLI## und ZFLIGHT##). Maintain the foreign keys appropriately in the new tables.

2.Copy the content of the original tables into the newly created tables using a report.

3.Create a two-step maintenance view (screen numbers e.g. 100 and 110) for every table copied.

4.Create a view cluster with the name ZPC_FLIGHT##.

5.Give a meaningful short description in the header entry.

6.Change to the object structure and enter the following new entries:

View/Tab.

Short description

Prede-

Dep

Pos

 

 

cessor

 

 

ZCARR##

Carriers

ZCARR##

R

1

ZPFLI##

Flight connections

ZCARR##

S

2

ZFLIGHT##

Flights of the connection

ZPFLI##

S

3

7.Generate the field dependencies for every entry in the list.

8.Activate the view cluster

9.Generate a new entry for an airline and create two flights each for these two new flight connections. Output the new entries via a report in a list.

200

© 2007 SAP AG. All rights reserved.

2006/Q2

BC430

Lesson: Maintenance Views

Solution 12: Maintenance Views

Task 1:

Create a maintenance view with the name ZPARTNER##, with which you can easily maintain new business partners.

Note: The business partners are entered in table SBUSPART. A business partner can be either a flight customer or a travel agency. If it is a travel agency, there will be a corresponding entry in table STRAVELAG.

The view should also permit you to maintain tables SBUSPART and STRAVELAG at one time. Include all the necessary fields of the tables in the view.

You want to maintain the data in tables SBUSPART and STRAVELAG together in the maintenance view. If you wanted to enter a new partner directly, you would first have to enter it in table SBUSPART. Only then could you enter the corresponding data in table STRAVELAG (because of the existing foreign key check between SBUSPART and STRAVELAG).

1.Generate the maintenance interface. Use the following parameters:

Continued on next page

2006/Q2

© 2007 SAP AG. All rights reserved.

201

Unit 7: Views and Maintenance Views

BC430

Function group

ZZBC430##

Authorization group

SUNI

Maintenance type

one-step

Overview screen

100

a)Mark the object type View in the initial screen of the ABAP Dictionary. Enter the object name ZPARTNER## and choose Create.

b)Select the view type in the dialog box. Mark Maintenance view and select Choose.

c)Enter a short text in the next screen. When defining the maintenance view, you first of all copy the SBUSPART table.

d)Enter the SBUSPART table in the Tables field. The key fields of this table are automatically included in the view as fields.

e)Place the cursor in the Tables field on the SBUSPART entry. Choose

Relationships.

A dialog box appears listing all existing foreign key relationships of table SBUSPART to other tables.

f)In the dialog box, mark the foreign key relationship for the STRAVELAG table and choose Copy.

g)The join conditions are created from the foreign key. The join conditions have the following form:

SBUSPART-MANDANT = STRAVELAG-CLIENT

SBUSPART-BUSPARTNUM = STRAVELAG-AGENCYNUM

2.Include the fields of both tables in the view.

a)Click on tab page View fields. Position the cursor on table SBUSPART and choose Table fields. A list of all the fields of the table appears. Choose Select all and then Copy.

b)Include all the fields of the STRAVELAG table with the exception of the fields CLIENT and AGENCYNUM in the view in the same way. These fields are linked to the corresponding fields of table SBUSPART with the join conditions and therefore should not appear in the view.

c)Activate the view.

Continued on next page

202

© 2007 SAP AG. All rights reserved.

2006/Q2

BC430

Lesson: Maintenance Views

3.Generate a maintenace interface for the view.

a)Choose Utilities → Table maintenance generator.

b)Enter authorization group SUNI and function group ZZBC430## in the next screen.

c)Mark maintenance type one-step. Select number 0100 as maintenance screen number of the overview screen.

d)Choose Create. The development class of the function group and the generated maintenance objects are prompted. In both cases, choose

Local object.

4.Then maintain the data of a new travel agency using the enhanced table maintenance. Choose System → Services → Table maintenance → Enhance. Tab.maint..

a)Enter the data of a new travel agency.

b)With the Data Browser (in the menu environment of the initial screen of the ABAP Dictionary), verify that the data of the new travel agency was written in tables SBUSPART and STRAVELAG.

Task 2:

Bundle maintenance view in a view cluster.

Note: You want to serve several maintenance views of dependent tables on one single transaction screen. To do this, create a complex maintenance view over several customer tables. In this exercise, use the table from the flight data model again. You will copy these tables including their entire content on the customer namespace.

1.First of all copy the tables SCARR, SPFLI and SFLIGHT into the customer namespace with attached monitor number (ZCARR##, ZPFLI## und ZFLIGHT##). Maintain the foreign keys appropriately in the new tables.

a)Copy and activate the tables using the SE11. Adjust the foreign key relationships ZPFLI## (CARRID -> ZCARR##) and ZFLIGHT## (CARRID -> ZCARR##, CONNID -> ZPFLI##)

2.Copy the content of the original tables into the newly created tables using a report.

a)See source text of the model solution. You can also find and copy the respective report in the system.

Continued on next page

2006/Q2

© 2007 SAP AG. All rights reserved.

203

Unit 7: Views and Maintenance Views

BC430

3.Create a two-step maintenance view (screen numbers e.g. 100 and 110) for every table copied.

a)You have two possibilities to go into the suitable screen of the transaction SE54:

1.In SE11, go to the corresponding table via menu path Utilities -> Table maintenance generator into the generation environment.

2.Start transaction SE54 and enter the repsective table.

Select Generated object and press the Create/Change button.

b)In the next screen, enter the authorization group SUNI and, as function group, the respective table names with the prefix ZFP_.

c)Mark the maintenance type two-step. Select the numbers 0100 and 0110 as maintenance screen numbers of the overview screen and of the individual screen.

d)Choose Create. The development class of the function group and the generated maintenance objects are prompted. In both cases, choose

Local object.

e)Proceed as with all copied tables.

4.Create a view cluster with the name ZPC_FLIGHT##.

a)Start the transaction SE54. In the initial screen, choose Edit View Cluster to access the screen for editing/creating a view cluster.

b)Enter the name of the cluster in the View cluster field.

c)Press the button Create/Change.

d)Ignore the message “No changes please (data belong to SAP)”. As long as you stay in the customer namespace (Z* or Y*), this message is meaningless. More exact information in SAP Note No.: 671067

5.Give a meaningful short description in the header entry.

6.Change to the object structure and enter the following new entries:

Continued on next page

204

© 2007 SAP AG. All rights reserved.

2006/Q2

BC430

Lesson: Maintenance Views

View/Tab.

Short description

Prede-

Dep

Pos

 

 

cessor

 

 

 

 

 

 

 

ZCARR##

Carriers

ZCARR##

R

1

 

 

 

 

 

ZPFLI##

Flight connections

ZCARR##

S

2

 

 

 

 

 

ZFLIGHT##

Flights of the connection

ZPFLI##

S

3

 

 

 

 

 

a)In the navigation window, double-click Dialog structure on the Object structure node

b)Press the button New entries.

c)Enter the values respectively in the table.

d)Select the ZCARR## table as the initial object via the START column.

7.Generate the field dependencies for every entry in the list.

a)Mark every line of the object structure and generate respectively the field dependencies via the button Field dependency

8.Activate the view cluster

a)Double-click the dialog for the header entry and press the button

Activate

9.Generate a new entry for an airline and create two flights each for these two new flight connections. Output the new entries via a report in a list.

a)Call up the transaction SM34.

b)Enter the name of your view cluster in the input field and activate the

Maintain button.

c)Import the new entries, beginning with ZCARR.

Note: You can navigate on the left-hand side of the screen and enter or change the data on the right-hand side.

d)The data are written on the database by using the Save button.

e)Write a report with the SE38 or the SE80 in ABAP, which issues the entries for the new carrier.

Result

REPORT SAPBC430S_FILL_CLUSTER_TAB

.

DATA wa_scarr TYPE scarr.

DATA wa_spfli TYPE spfli.

DATA wa_flight TYPE sflight.

Continued on next page

2006/Q2

© 2007 SAP AG. All rights reserved.

205

Unit 7: Views and Maintenance Views

BC430

DATA my_error TYPE i VALUE 0.

START-OF-SELECTION.

*Replace ## by Your user-number

DELETE FROM zcarr##. DELETE FROM zpfli##. DELETE FROM zflight##.

SELECT * FROM scarr INTO wa_scarr. INSERT INTO zcarr## VALUES wa_scarr.

ENDSELECT.

IF sy-subrc = 0.

SELECT * FROM spfli INTO wa_spfli. INSERT INTO zpfli## VALUES wa_spfli.

ENDSELECT.

IF sy-subrc = 0.

SELECT * FROM sflight INTO wa_flight.

INSERT INTO zflight## VALUES wa_flight.

ENDSELECT.

IF sy-subrc <> 0. my_error = 1.

ENDIF.

ELSE.

my_error = 2. ENDIF.

ELSE.

my_error = 3. ENDIF.

IF my_error = 0.

WRITE / 'Datatransport successfully finished'.

ELSE.

WRITE: / 'ERROR:', my_error.

ENDIF.

206

© 2007 SAP AG. All rights reserved.

2006/Q2

BC430

Lesson: Maintenance Views

Lesson Summary

You should now be able to:

Create a maintenance view

Create simple maintenance views

Create complex maintenance views

2006/Q2

© 2007 SAP AG. All rights reserved.

207

Unit Summary

BC430

Unit Summary

You should now be able to:

Judge how a view is created from tables with join, projection, and selection

Create database views

Set up a link between foreign keys and join conditions

Use views in programs for data selection

Judge when to use maintenance views

Recognize the difference between an inner join and an outer join

Create a maintenance view

Create simple maintenance views

Create complex maintenance views

208

© 2007 SAP AG. All rights reserved.

2006/Q2

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]