36
Data Dictionary in ABAP Day 2

DDIC Training Day 2

Embed Size (px)

DESCRIPTION

DDIC Training Day 2

Citation preview

Page 1: DDIC Training Day 2

Data Dictionary in ABAP

Day 2

Page 2: DDIC Training Day 2

2Copyright © 2009 Deloitte Development LLC. All rights reserved.

Content – Day 2• Changes to Database Tables :

– 1. Change to database tables– 2. Effect of changes to the table structure– 3. Database Utility – 4. Append Structures

• Indexes

• Views :– 1. Why Do we need Views?– 2. Join Conditions and Foreign Keys– 3. Project views– 4. Database views– 5. Maintenance Views

• Search Help Objects– 1. Elementary Search Help– 2. Collective Search Help

• Lock Objects

Page 3: DDIC Training Day 2

3Copyright © 2009 Deloitte Development LLC. All rights reserved.

Page 4: DDIC Training Day 2

4Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 1999

ABAP Dictionary

Changes to Tables

Active versioninactive version

Field 1 Field 2 Field 3

Field 2 Field 3Field 1 Field 4

Field 2 Field 3Field 1

Database

Page 5: DDIC Training Day 2

5Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 1999

How is the Structure Adjusted?

Field 1 Field 2 Field 3

Active version

Inactive versionDelete, create again

or

Change catalog for the DB (ALTER TABLE)

or

Convert the table

Field 2 Field 3Field 1

Field 2 Field 3Field 1 Field 4

Does the table contain data?

What databasesystem is used?

What change was made?

Page 6: DDIC Training Day 2

6Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 2002

Append Structures 1

Field 1 Field 2 Field 3 Field A Field B

Table

Field 2 Field 3Field 1

Append structure

Field A Field B

Page 7: DDIC Training Day 2

7Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 2002

Append Structures 2

New SAP version is imported

Field 1 Field 2 Field 3 Field A Field B

Append structure

Field A Field B

Table

Field 2 Field 3Field 1

Field 2 Field 3Field 1 Field 4

Page 8: DDIC Training Day 2

8Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAPAG 2002

Append Structures 3

Append the fieldon the database

Table

Activate

Field 1Field 2 Field 3 Field A Field B Field 4

Append structure

Field AField B

Field 2Field 3Field 1 Field 4

Page 9: DDIC Training Day 2

9Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 2002

Summary

The runtime object and database definition of a table must always be consistent. For this reason, the corresponding database table must be adjusted when you change a table in the ABAP Dictionary.

The system always tries to make structure changes to tables by changing the database catalog (ALTER TABLE). If this is not possible, a conversion takes place.

In a conversion, the data is stored in a temporary table and then copied back to the table with its new structure.

Customer fields should always be added to SAP standard tables using append structures.

Page 10: DDIC Training Day 2

10Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 1999

Indexes

Primary index and secondary index

Structure of an index

Data access using an index

Table buffering

Advantages of buffering

Local table buffers

Buffering types

Buffer synchronization

Which tables should be buffered?

Performance during Table Access

Page 11: DDIC Training Day 2

11Copyright © 2009 Deloitte Development LLC. All rights reserved.

Page 12: DDIC Training Day 2

12Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 2002

TABIndex AF2 Z F1 F2 F3

10A3 10 Text

Access with Indexes

Index 0F1 Z

Optimizer

SELECT * FROM TAB WHERE F2 = `10´.

Program

Page 13: DDIC Training Day 2

SAP AG 2002

Why do you need views?

Creating a view by join, projection, and selection

Join conditions and foreign keys

Selection of data with views

Database views

Maintenance views

Inner and outer joins

Views

Page 14: DDIC Training Day 2

14Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 1999

F3F2F1F4 F5

F6 F7 F8

Table 3Table 2

Table 1

View on the tables

View on data that is distributed on more than one table

Why do you Need Views?

F1 F2 F3 F5 F8

Page 15: DDIC Training Day 2

15Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 2002

Table TABA

Table TABB

1 1

12

22

Text 1 Text 3

Text 4Text 5

Text 2

Text 6

A

AB

B

Field 1 Field 2 Field 3 Field 4 Field 5

Field 1 Field 2 Field 3 Field 4 Field 5

1 Text 11 Text 11 Text 11 Text 12 Text 22 Text 22 Text 22 Text 2

1

122

Text 3

Text 4Text 5Text 6

A

AB

B1

122

Text 3

Text 4Text 5Text 6

A

AB

B

Cross-product of tables TABA and TABB

Structure of a View - Starting Situation

Page 16: DDIC Training Day 2

16Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 1999

Join condition: TABA - Field 1 = TABB - Field 3

Field 1 Field 2 Field 3 Field 4 Field 5

1 Text 11 Text 11 Text 11 Text 12 Text 22 Text 22 Text 22 Text 2

1

122

Text 3

Text 4Text 5Text 6

A

AB

B1

122

Text 3

Text 4Text 5Text 6

A

AB

B

Reduction of the cross-product

Structure of a View - Join Condition

Page 17: DDIC Training Day 2

17Copyright © 2009 Deloitte Development LLC. All rights reserved.

Joins

Page 18: DDIC Training Day 2

18Copyright © 2009 Deloitte Development LLC. All rights reserved.

Types of Views

- Project ion View

- Maintenance View

- Database View

- Help View

Page 19: DDIC Training Day 2

19Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 1999

Field 1 Field 2 Field 4 Field 5

1 Text 11 Text 12 Text 22 Text 2

Text 3

Text 4

A

BText 5Text 6

AB

Field 1 Field 2 Field 5

1 Text 11 Text 12 Text 22 Text 2

Text 3

Text 4Text 5Text 6

Projection

Structure of a View - Field Selection (Projection)

Page 20: DDIC Training Day 2

20Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 1999

F6 F7 F8

Table 3

F4 F5

Table 2

F3F2F1

Table 1

View definition in the ABAP Dictionary

View definition in the database

Is created in the DBduring activation

ABAP program

F1 F2 F3 F5 F8

F1 F2 F3 F5 F8

Database Views

Database interface

Page 21: DDIC Training Day 2

21Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 1999

F6 F7 F8Table 3

F3F2F1Table 1

Table 2F4 F5

Maintenance view on the tables

Data exchange with the maintenance view

Foreign key Foreign key

F1 F2 F3 F5 F8

Maintenance Views

Application object

Page 22: DDIC Training Day 2

22Copyright © 2009 Deloitte Development LLC. All rights reserved.

SAP AG 2002

Unit Summary

Data records that are distributed on different tables can be combined using a view.

A view is derived from the tables involved using the relational operators join, projection, and selection.

ABAP programs can select data using a view. Selection with a database view is usually faster than direct table selection with a nested SELECT statement.

You can maintain data records from several tables together using a maintenance view.

Page 23: DDIC Training Day 2

23Copyright © 2009 Deloitte Development LLC. All rights reserved.

Search Help

• The input help (F4 help) is a standard function of the R/3 System. The user can display the list of all possible input values for a screen field with the input help.

Standard Input Help ProcessA user calls an input help with the following

steps:• The user starts the input help to display the

possible input values for a field (search field) in a screen.

• The system offers the user a number of possible search paths. The user selects one of these search paths. Each search path offers a number of restrictions to limit the number of possible input values. These values are offered in a Dialog box for value restriction when the search path is selected.

• The user enters restrictions if required and then starts the search.

Page 24: DDIC Training Day 2

24Copyright © 2009 Deloitte Development LLC. All rights reserved.

• The system determines the values that satisfy the entered restrictions (hits) and displays them as a list (hit list).

• The user selects the most suitable line from the hit list by double-clicking. • The value of the search field is returned to the screen template (possibly together with

other values).

Search Help

Page 25: DDIC Training Day 2

25Copyright © 2009 Deloitte Development LLC. All rights reserved.

Page 26: DDIC Training Day 2

26Copyright © 2009 Deloitte Development LLC. All rights reserved.

Types of Search Help

There are two types of search help:• Elementary search helps : The elementary search help must define

where the data of the hit list should be read from (selection method), how the exchange of values between the screen template and selection method is implemented (interface of the search help) and how the online input help should be defined (online behavior of the search help).

• Collective search helps combine several elementary search helps. A collective search help thus can offer several alternative search paths.

Page 27: DDIC Training Day 2

27Copyright © 2009 Deloitte Development LLC. All rights reserved.

Elementary Search Help• An elementary search help defines the standard flow of an input help. You can define the following

components of this flow in the search help:

• where does the data displayed in the hit list come from (selection method)

• what information should be displayed in the dialog box for value selection and in the hit list (search help parameters)

• what field contents can be taken into account for hit list selections and which values in the hit list can be returned to the screen fields (search help parameters)

• what dialog steps should be executed in the input help (dialog behavior)

• Restrict the entries displayed in the input help based on some conditions which is not possible using a View (Search help exit).

Page 28: DDIC Training Day 2

28Copyright © 2009 Deloitte Development LLC. All rights reserved.

Selection method:

• If all the data required in the hit list comes from one single table, you only have to select this table (or a projection view on this table) as selection method.

• If there is a text table for the table, its fields are also available in the input help. A table entry is linked with the corresponding text by the existing foreign key.

• If the data needed in the hit list comes from more than one table, you must link these tables with a view (database view or help view). This view must be defined as the selection method.

• If the underlying tables are client-specific, the client field must be contained in the view. Otherwise selection for the input help would be for all clients.

Elementary Search Help

Page 29: DDIC Training Day 2

29Copyright © 2009 Deloitte Development LLC. All rights reserved.

• A search help has an interface consisting of parameters. These parameters define the fields of the selection method that should be used in the input help.

• A parameter of the search help must correspond to each field in the dialog box for value selection and to each field of the hit list. The parameters are copied from the corresponding selection method, that is they always have the same name as the corresponding field of the selection method.

• If the search is restricted with a parameter of the search help, this is used in the data selection for formulating a WHERE condition for the field of the selection method with the same name. Vice versa, the parameters of the search help are assigned the contents of the fields of the selection method having the same name.

• The search help should not contain any parameters for the clients. In the input help, selection is automatically in the logon client of the user.

• A data element must be assigned to each search help parameter, that is a type is always defined for the search help parameters.

Search Help Parameters

Page 30: DDIC Training Day 2

30Copyright © 2009 Deloitte Development LLC. All rights reserved.

• The interface of a search help defines the context data that can be used in the input help and the data that can be returned in the input template.

• A parameter of a search help can be classified as:• Import parameters: Parameters with which context information from the processed input

template (screen) may be copied to the help process.

• Export parameters: Parameters with which values from the hit list may be returned to the input template. A parameter can simultaneously be an input and an export parameter.

Search Help Parameters

Page 31: DDIC Training Day 2

31Copyright © 2009 Deloitte Development LLC. All rights reserved.

Dialog Behavior

Dialog type• Display values immediately – The hit list is displayed directly when the user clicks on “F4”

on the screen field. This option is usually used when the hit list is expected to have less entries.

• Dialog with value restriction – A dialog box with options further to restrict the selection of values will be displayed first. On clicking on “Enter”, hit list with all valid values will be displayed. This is used when the hit list is expected to have more entries.

• Dialog depends on set of values – It behaves like Dialog values immediately when the number of entries are less(say 100) and like Dialog with restriction when the hit list is expected to have more entries.

Hot Key• Hot keys are used to directly select an elementary search help from a collective search

help. Hot keys are usually used when a specific search criteria is used frequently for searches.

Page 32: DDIC Training Day 2

32Copyright © 2009 Deloitte Development LLC. All rights reserved.

Search help exit

• A search help exit is used when the hit list is to be restricted based on some conditions which cannot be achieved by selection method.

• A search help exit is a function module. User specific code should be added to the appropriate step in the function module.

Page 33: DDIC Training Day 2

33Copyright © 2009 Deloitte Development LLC. All rights reserved.

Structure of Collective Search Help

• A collective search help combines several elementary search helps. The user can thus choose one of several alternative search paths with a collective search help.

• When you define a collective search help, you only have to specify the search helps that are to be combined in the collective search help. In the input help, the values are transported between the elementary search help selected by the user and the input template using the collective search help. This is why a collective search help also has an interface for transporting the values.

Page 34: DDIC Training Day 2

34Copyright © 2009 Deloitte Development LLC. All rights reserved.

• Like an elementary search help, a collective search help has an interface of import and export parameters. The data is exchanged between the screen template and the parameters of the assigned elementary search helps using this interface.

Interface of the Collective Search Help

Page 35: DDIC Training Day 2

35Copyright © 2009 Deloitte Development LLC. All rights reserved.

• A collective search help comprises several elementary search helps. It combines all the search paths that are meaningful for a field.

• The interface parameters (import and export parameters) of the included search helps must be assigned to the parameters of the collective search help. Not all of the parameters need to be assigned, that is the assignment can be open for some of the parameters.

• Both elementary search helps and other search helps can be included in a collective search help. If other collective search helps are contained in a collective search help, they are expanded to the level of the elementary search helps when the input help is called.

Assigned Search Helps

Page 36: DDIC Training Day 2

36Copyright © 2009 Deloitte Development LLC. All rights reserved.

• Simultaneous accessing of the same data record by two users in the SAP system is synchronized by a lock mechanism.

• Locks are set and released by calling certain function modules. These function modules are generated automatically from the definition of so-called lock objects in the ABAP/4 Dictionary

• Function modules :– Enqueue_<obj name> - to lock the table– Dequeue_<obj name> - to release the lock

Lock Objects