3.ecl fi abap abapdictionary objects

79
PricewaterhouseCoopers ABAP Dictionary Objects Tables Views Data Elements Domains Search Help Lock Objects Using a Table in an ABAP Program

Upload: anonymous-0v9zwxz6hf

Post on 19-Jul-2016

14 views

Category:

Documents


1 download

DESCRIPTION

ABAP

TRANSCRIPT

Page 1: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

ABAP Dictionary Objects

Tables

Views

Data Elements

Domains

Search Help

Lock Objects

Using a Table in an ABAP Program

Page 2: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Basic Objects of the ABAP Data Dictionary

Table CTable BTable A

Data Element 1 Data Element 2

DomainDomain

Page 3: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Tables

TABLE KNA1TABLE KNA1(Customers)(Customers)

Name 1 ORT 02MANDT KUNNRTable: KNA1Table: KNA1

Page 4: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Create a Table

Enter a description (short text).

Maintain delivery class

Table Maintenance attributes

Page 5: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Create a Table

Maintain field attributes

Page 6: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Two-Level Domain Concept

Data Element 1 Data Element 2

DomainDomain

Page 7: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Data Elements

Table BTable A

Data Element 1

Page 8: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Pre-Defined Data Elements

Page 9: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Data Element Documentation

Page 10: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Create Data Element

Enter a description (short text).

Enter domain name.

Page 11: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Create Data Element

Maintain field labels and column headers.

Page 12: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Domains

Table ATable A

Data ElementsData Elements

DomainDomain

Page 13: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Characteristics of Domains

Table ATable A

Data ElementsData Elements

DomainDomain

Page 14: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Allowed Values

Value Table

DomainDomain DomainDomain

JanuaryFebruaryMarch . . . . . . .December

Page 15: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

validvalues

invalidvalues

Benefits of Using Allowed Values

Page 16: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Create a Domain

Enter a description (short text).

Enter data type and length.

Page 17: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Create a Domain

Explicit values or a valuetable may be entered.

Page 18: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Using a Table in Program Code

TABLES:YEMPLOY.

SELECT *FROM YEMPLOY.

WRITE:/ YEMPLOY-IDYEMPLOY-NAMEYEMPLOY-SALARY

ENDSELECT.

Page 19: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Foreign Key Relationships

Definition & Uses of Foreign Keys

Prerequisites for Constructing Foreign Key Relationships

Key Terminology

Cardinality and Foreign Key Field Types

Foreign Keys with Multiple Fields

Page 20: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Definition of Foreign Keys

Page 21: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Uses of Foreign Keys

Maintain data integrity

Provide help texts

Create aggregate dictionary objects

Page 22: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Prerequisites for Constructing Foreign Key Relationships

The foreign key field and the primary key of the check table must share the same domain.

A value table must exist for that domain.

Page 23: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Check TableCheck Table

Value TableValue Table

Foreign Keys: Key Terminology

Foreign Key TableForeign Key Table

Page 24: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Let’s review some of the key terminology relating to foreign keys.Value table: The table containing the set of allowed values attached to a domain.Check table: The table that is referenced by a foreign key. A check table is either identical to a value table, or is another table containing a subset of the records in a value table.Foreign key table: The table containing fields that are the primary key of the other table. The foreign key table is also known own as the “dependent” or “child” table.

Page 25: 3.ECL FI ABAP ABAPDictionary Objects

Slide 25 PricewaterhouseCoopers

EXAMPLE:

For example, suppose a telephone company stores general customer information in the CUSTOMERS table and stores specialised information about business customers in the BUSINESS_CUSTOMERS table.

Suppose that there was also a BUSINESS_OWNERS table that listed the owners of all business customers. The BUSINESS_OWNERS table might consist of two fields: Customer ID and the name of each individual owner.

In this case, we would establish a foreign key relationship between the BUSINESS_OWNERS table and the BUSINESS-CUSTOMERS table.

The value table for the customer ID field in the BUSINESS_OWNERS table would be the CUSTOMERS table, but the check table would be the BUSINESS_CUSTOMERS table.

The foreign key table would be the BUSINESS_OWNERS table.

Page 26: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Creating a Foreign Key Relationship

Foreign key push-button

Page 27: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Cardinality

n n : : m m1

C

1

C

N

CN

djnsh338
Page 28: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

When creating foreign key relationships, you should always specify the cardinality of that relationship. Here is a reminder of the possible values for each side of the n : m notation that SAP uses to specify cardinality. For a fuller review of cardinality, see Chapter 2.For the left side:n = 1 Each record in the foreign key table refers to exactly one record in the check table.n = C Each record in the foreign key table refers to zero or one records in the check table.For the right side:m = 1 Each record in the check table has exactly one

dependent record. m = C Each record in the check table has a zero or one

dependent records. m = N Each record in the check table has at least one

dependent record. m = CNEach record in the check table has zero, one, or many dependent entities.

Page 29: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Maintaining a Foreign Key Relationship’s Attributes

Check table(defaults tovalue table)

Enter a description (short text).

Maintain cardinality n : m

Maintain foreignkey type

Page 30: 3.ECL FI ABAP ABAPDictionary Objects

Slide 30 PricewaterhouseCoopers

Foreign Key Field Type:

The foreign key field type indicates whether the foreign key fields belong to the primary key (or a candidate key) of the foreign key table.

A candidate key is a field or combination of fields that uniquely identifies a record, but it is not necessarily the primary key of that table. (In some tables, there are multiple candidates for the primary key, but only one combination can be selected to be the primary key.)

Key Fields of a Text Table are a special instance of Key Fields or Key Field Candidates. An additional condition in this case is that the dependent table is a language-dependent text table for the referenced table. The key of the text table is composed of the key of the referenced table and a language key.

For example, the table T005T contains language-dependent descriptions of country codes. The key fields of this table are client (MANDT), language key (SPRAS), and country key (LAND1). The foreign key type of the foreign key on the field LAND1 is Key Fields of a Text Table. This is because LAND1 and SPRAS (the language key) are both part of the primary key of T005T.

Foreign key fields that do not belong to the identifying fields of the foreign key table are of the type: Non-key Field Candidates.

Page 31: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

ABAP Dictionary Tablesin Relational Databases

SAP Table Types

Technical Settings

Indexes

Page 32: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

SAP Table Types

Transparent Table (TRANSP) Structure (INTTAB)

Pool Table Cluster Table

View

Page 33: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Transparent TablesType = TRANSP

Master DataMaster Data

Page 34: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Table Types TRANSPin the Database

DB

PROFILE

Page 35: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Pool Tables: Overview

Page 36: 3.ECL FI ABAP ABAPDictionary Objects

Slide 36 PricewaterhouseCoopers

Cluster Tables : Overview

Page 37: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Technical Settings

Master Transaction

Organization & Customizing

User

Data class

Number of data records in DB storage

Single records, generic, full, not buffered

on or off

Size category

Buffering

Log data changes

Page 38: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Master data User data

Data Class

Organization and Customizing dataTransaction data

DB

Page 39: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Size Categories

Page 40: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Buffering Type

None

Single Record Generic

Full

KF1 KF2 KF3 F4 F5 F6 KF1 KF2 KF3 F4 F5 F6

KF1 KF2 KF3 F4 F5 F6

Page 41: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Maintaining Technical Settings

Page 42: 3.ECL FI ABAP ABAPDictionary Objects

Slide 42 PricewaterhouseCoopers

Table Logging

Transaction code : SCU3

Page 43: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Table Index: Primary Index

Page 44: 3.ECL FI ABAP ABAPDictionary Objects

Slide 44 PricewaterhouseCoopers

Table Index: Secondary Index

Page 45: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

ABAABAP P DictiDictionaronar

yy

DB

Database Utility

Page 46: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

ABAP Dictionary Objects: Views

Definition

Relational operations

Types of views

Using a view in program code

Page 47: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

What is a View?

Page 48: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

The Most Basic Form of a View

Page 49: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

The Relational Operations

Table 2Selection

View BView B

Table 1Projection

View View AA

View CView C

JoinTable 4Table 4Table 3Table 3

Page 50: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

The Projection Operation

Projection

View AView A

Table 1

Page 51: 3.ECL FI ABAP ABAPDictionary Objects

Slide 51 PricewaterhouseCoopers

Specifying Projected Fields

Can use any name if database view, Can use any name if database view, otherwise must be same name as table field.otherwise must be same name as table field.

Indicate actual table Indicate actual table Fields and data elements.Fields and data elements.

Page 52: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

The Selection Operation

Selection

View BView B

Table 2

Example:Staff Level <= 3

Page 53: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Specifying Selection Criteria

1 3 52 4

Can include unprojected fields

Page 54: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

The Join Operation

Table Table 33

Join

Table Table 44

View CView C

Page 55: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Inner Join & Outer Join

Page 56: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

ID Salary Date Effective

5579 $10,000.00 10/1/91

5579 $11,000.00 10/1/92

5579 $12,000.00 10/1/94

5579 $13,000.00 10/1/96

Understanding the Join Operation

ID Name …

EmployeeEmployee

SalarySalary

Right

Page 57: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

The Join Operation and Foreign Keys

View CView C

Join

Table 4Table 4Table 3Table 3Primary Secondary

Page 58: 3.ECL FI ABAP ABAPDictionary Objects

Slide 58 PricewaterhouseCoopers

Specifying Joined Fields

Hit button to see related tables and Hit button to see related tables and automatically generate join conditions.automatically generate join conditions.

Indicate base tables that data will come from.Indicate base tables that data will come from.

Page 59: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Types of Views in the ABAPDictionary

Database View

Projection View

Help View

Maintenance View

Page 60: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

The Database View

Page 61: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

The Projection View

Page 62: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Help View

Page 63: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Maintenance ViewTransaction : SM30, SE54

Page 64: 3.ECL FI ABAP ABAPDictionary Objects

PricewaterhouseCoopers

Using a View in Program Code

TABLES: YXXEMP_V.

SELECT *FROM YXXEMP_V.

WRITE: / YXXEMP_V-EMP_IDYXXEMP_V-LAST_NAME,YXXEMP_V-FIRST_NAME.

ENDSELECT.

Page 65: 3.ECL FI ABAP ABAPDictionary Objects

Slide 65 PricewaterhouseCoopers

Overview of Search Helps

Benefits of Search Helps

Elementary Search Helps

Collective Search Helps

Search Help Exits

Page 66: 3.ECL FI ABAP ABAPDictionary Objects

Slide 66 PricewaterhouseCoopers

The Benefits of Search Helps

What was Smith’sWhat was Smith’s vendor number, vendor number,

anyway?anyway?

F4F4

Page 67: 3.ECL FI ABAP ABAPDictionary Objects

Slide 67 PricewaterhouseCoopers

Elementary vs. Collective

CollectiveCollectiveSearch HelpSearch Help

EElleemmeennttaarryy

11

Field H

Field B

Field K

EElleemmeennttaarryy

22

Field Z

Field O

EElleemmeennttaarryy

33

Field A

EElleemmeennttaarryy

44

Field RField XField BField OField Q

Page 68: 3.ECL FI ABAP ABAPDictionary Objects

Slide 68 PricewaterhouseCoopers

Creating an Elementary Search Help

Create search help from Dictionary pushbutton on Create search help from Dictionary pushbutton on workbench, or from within Repository Browser.workbench, or from within Repository Browser.

Page 69: 3.ECL FI ABAP ABAPDictionary Objects

Slide 69 PricewaterhouseCoopers

Defining an Elementary Search Help

OptiOptional onal exitexit

Hit List Hit List Display Display MethodMethod

Used to Used to identify identify

search helpsearch help

Data source Data source for hit listfor hit list

Interface Interface ParameteParamete

rsrs

Page 70: 3.ECL FI ABAP ABAPDictionary Objects

Slide 70 PricewaterhouseCoopers

Defining an Elementary Search Help - Interface Parameters

Parameters for values you Parameters for values you want to send and receivewant to send and receive

Declaration of parameters Declaration of parameters as import and/or exportas import and/or export

Parameter is display onlyParameter is display only

Data element associatedData element associatedwith parameterwith parameter

Position parameterPosition parameterwill be on hit listwill be on hit list Position parameter will Position parameter will

be on dialog boxbe on dialog box

Optional defaultOptional defaultfor parameterfor parameter

Page 71: 3.ECL FI ABAP ABAPDictionary Objects

Slide 71 PricewaterhouseCoopers

Assigning an Elementary Search Help - Priority Levels

TableTable

Data ElementData Element

FieldField

Page 72: 3.ECL FI ABAP ABAPDictionary Objects

Slide 72 PricewaterhouseCoopers

Using Elementary Search Helps

F4F4

Page 73: 3.ECL FI ABAP ABAPDictionary Objects

Slide 73 PricewaterhouseCoopers

Defining a Collective Search Help - Interface

Notice there is no selection method. Notice there is no selection method. AA

collective search help is a set of one collective search help is a set of one oror

more elementary search helps.more elementary search helps.

Page 74: 3.ECL FI ABAP ABAPDictionary Objects

Slide 74 PricewaterhouseCoopers

Defining a Collective Search Help -Adding Elementary Search Helps

Don’t forget to assign parameters Don’t forget to assign parameters for each elementary search help.for each elementary search help.

Page 75: 3.ECL FI ABAP ABAPDictionary Objects

Slide 75 PricewaterhouseCoopers

Using a Collective Search Help

F4F4

Only difference from Only difference from Before - toggle tab Before - toggle tab

between elementary between elementary Search helps.Search helps.

Page 76: 3.ECL FI ABAP ABAPDictionary Objects

Slide 76 PricewaterhouseCoopers

Lock Object

Naming Convention : Starts with “E”

Lock Object will generate 2 function modules:

ENQUEUE_<LOBJ.NAME>

DEQUEUE_<LOBJ.NAME>

Page 77: 3.ECL FI ABAP ABAPDictionary Objects

Setting & Releasing Lock:

Setting the lock :Call function ENQUEUE_<LOBJ.NAME>UPDATE < LOBJ.NAME>

Releasing the lock:Call function DEQUEUE_<LOBJ.NAME>

Page 78: 3.ECL FI ABAP ABAPDictionary Objects

Slide 78 PricewaterhouseCoopers

Lock Object Details

Page 79: 3.ECL FI ABAP ABAPDictionary Objects

Slide 79 PricewaterhouseCoopers

Lock Objects Parameters