Vous êtes sur la page 1sur 36

Data Dictionary in ABAP

Day 2

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

Copyright 2009 Deloitte Development LLC. All rights reserved.

Copyright 2009 Deloitte Development LLC. All rights reserved.

Changes to Tables

ABAP Dictionary
Field 1 Field 2 Field 3

Active version

inactive version
Field 1 Field 2 Field 3 Field 4

Field 1 Field 2 Field 3

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

SAP AG 1999

How is the Structure Adjusted?

Field 1 Field 2 Field 3

What change was made?

Active version
Field 1 Field 2 Field 3 Field 4

Inactive version Does the table contain data?

Delete, create again or Change catalog for the DB (ALTER TABLE)

What database system is used?

or Convert the table

Field 1 Field 2 Field 3

Copyright 2009 Deloitte Development LLC. All rights reserved.

SAP AG 1999

Append Structures 1

Field A Field B

Table
Field 1 Field 2 Field 3

Append structure

Field 1 Field 2 Field 3 Field A Field B

Copyright 2009 Deloitte Development LLC. All rights reserved.

SAP AG 2002

Append Structures 2

Field A Field B

Table
Field 1 Field 2 Field 3

Append structure

New SAP version is imported


Field 1 Field 2 Field 3 Field 4

Field 1 Field 2 Field 3 Field A Field B

Copyright 2009 Deloitte Development LLC. All rights reserved.

SAP AG 2002

Append Structures 3

Field A Field B

Table
Field 1 Field 2 Field 3 Field 4

Append structure

Activate

Append the field on the database

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

Copyright 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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

SAP AG 2002

Performance during Table Access

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?

Copyright 2009 Deloitte Development LLC. All rights reserved.

10

SAP AG 1999

Copyright 2009 Deloitte Development LLC. All rights reserved.

11

Access with Indexes

Program

SELECT * FROM TAB WHERE F2 = `10.

Optimizer
Index 0 F1 Z Index A F2 Z 10 A3 10 Text
Copyright 2009 Deloitte Development LLC. All rights reserved. 12

TAB F1 F2 F3

SAP AG 2002

Views

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

SAP AG 2002

Why do you Need Views?

View on the tables F1 F2 F3 F5 F8

View on data that is distributed on more than one table

F1 F2 F3

F4

F5

F6 F7 F8

Table 1

Table 2

Table 3

Copyright 2009 Deloitte Development LLC. All rights reserved.

14

SAP AG 1999

Structure of a View - Starting Situation

Table TABA

Field 1 Field 2 1 2 Text 1 Text 2

Field 3 Field 4 Field 5 1 1 2 2 A B A B Text 3 Text 4 Text 5 Text 6

Table TABB

Field 1 Field 2 Field 3 Field 4 Field 5 1 Text 1 1 Text 1 1 Text 1 1 Text 1 2 Text 2 2 Text 2 2 Text 2 Copyright 2009 Deloitte Development LLC. All rights reserved. 2 Text 2
SAP AG 2002

1 1 2 2 1 1 2 2

A B A B A B A 15 B

Text 3 Text 4 Text 5 Text 6 Text 3 Text 4 Text 5 Text 6

Cross-product of tables TABA and TABB

Structure of a View - Join Condition

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


Field 1 Field 2 Field 3 Field 4 Field 5 1 1 1 1 2 2 2 2 Text 1 Text 1 Text 1 Text 1 Text 2 Text 2 Text 2 Text 2 1 1 2 2 1 1 2 2 A B A B A B A B Text 3 Text 4 Text 5 Text 6 Text 3 Text 4 Text 5 Text 6

Reduction of the crossproduct

Copyright 2009 Deloitte Development LLC. All rights reserved.

16

SAP AG 1999

Joins

Copyright 2009 Deloitte Development LLC. All rights reserved.

17

Types of Views

- Project ion View - Maintenance View - Database View - Help View

Copyright 2009 Deloitte Development LLC. All rights reserved.

18

Structure of a View - Field Selection (Projection)

Field 1 Field 2 Field 4 Field 5 1 1 2 2 Text 1 Text 1 Text 2 Text 2 A B A B Text 3 Text 4 Text 5 Text 6

Projection
Field 1 Field 2 Field 5 1 1 2 2
Copyright 2009 Deloitte Development LLC. All rights reserved.

Text 1 Text 1 Text 2 Text 2


19

Text 3 Text 4 Text 5 Text 6

SAP AG 1999

Database Views

ABAP program View definition in the ABAP Dictionary F1 F2 F3 F5 F8 Database interface

Is created in the DB during activation

F1

F2

F3

F5

F8

View definition in the database

F1 F2 F3

F4

F5

F6 F7 F8

Table 1
Copyright 2009 Deloitte Development LLC. All rights reserved.

Table 2
20

Table 3

SAP AG 1999

Maintenance Views

Application object

Maintenance view on the tables

F1

F2

F3

F5

F8 Data exchange with the maintenance view

Table 1 F1 F2 F3

Table 2 F4 F5

Table 3 F6 F7 F8

Copyright 2009 Deloitte Development LLC. All rights reserved.

Foreign key

21

Foreign key

SAP AG 1999

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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

22

SAP AG 2002

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 Process A 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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

23

Search Help
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).

Copyright 2009 Deloitte Development LLC. All rights reserved.

24

Copyright 2009 Deloitte Development LLC. All rights reserved.

25

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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

26

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).

Copyright 2009 Deloitte Development LLC. All rights reserved.

27

Elementary Search Help


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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

28

Search Help Parameters


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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

29

Search Help Parameters


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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

30

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.
Copyright 2009 Deloitte Development LLC. All rights reserved. 31

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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

32

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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

33

Interface of the Collective Search Help


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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

34

Assigned Search Helps


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.

Copyright 2009 Deloitte Development LLC. All rights reserved.

35

Lock Objects
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

Copyright 2009 Deloitte Development LLC. All rights reserved.

36

Vous aimerez peut-être aussi