You are on page 1of 79

PricewaterhouseCoopers

ABAP Dictionary Objects


Tables
Views
Data Elements
Domains
Search Help
Lock Objects
Using a Table in an ABAP Program
PricewaterhouseCoopers
Basic Objects of the ABAP
Data Dictionary
Table C Table B Table A
Data Element 1 Data Element 2
Domain
PricewaterhouseCoopers
Tables
TABLE KNA1
(Customers)
Name 1 ORT 02 MANDT KUNNR
Table: KNA1
PricewaterhouseCoopers
Create a Table
Enter a description (short text).
Maintain delivery class
Table Maintenance attributes
PricewaterhouseCoopers
Create a Table
Maintain field attributes
PricewaterhouseCoopers
Two-Level Domain Concept
Data Element 1 Data Element 2
Domain
PricewaterhouseCoopers
Data Elements
Table B Table A
Data Element 1
PricewaterhouseCoopers
Pre-Defined Data Elements
PricewaterhouseCoopers
Data Element Documentation
PricewaterhouseCoopers
Create Data Element
Enter a description (short text).
Enter domain name.
PricewaterhouseCoopers
Create Data Element
Maintain field labels and column headers.
PricewaterhouseCoopers
Domains
Table A
Data Elements
Domain
PricewaterhouseCoopers
Characteristics of Domains
Table A
Data Elements
Domain
PricewaterhouseCoopers
Allowed Values
Value Table
Domain
Domain
January
February
March
.
.
.
.
.
.
.
December
PricewaterhouseCoopers
valid
values
invalid
values
Benefits of Using Allowed Values
PricewaterhouseCoopers
Create a Domain

Enter a description (short text).
Enter data type and length.
PricewaterhouseCoopers
Create a Domain
Explicit values or a value
table may be entered.
PricewaterhouseCoopers
Using a Table in Program Code
TABLES: YEMPLOY.

SELECT *
FROM YEMPLOY.

WRITE: / YEMPLOY-ID
YEMPLOY-NAME
YEMPLOY-SALARY

ENDSELECT.
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
PricewaterhouseCoopers
Definition of Foreign Keys
PricewaterhouseCoopers
Uses of Foreign Keys
Maintain data integrity
Provide help texts
Create aggregate dictionary 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.
PricewaterhouseCoopers
Check Table
Value Table
Foreign Keys: Key Terminology
Foreign Key Table
PricewaterhouseCoopers
Lets 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.

PricewaterhouseCoopers Slide 25
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.

PricewaterhouseCoopers
Creating a Foreign Key
Relationship
Foreign key push-button
PricewaterhouseCoopers
Cardinality
n : m
1
C
1
C
N
CN
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 = CN Each record in the check table has zero, one, or
many dependent entities.

PricewaterhouseCoopers
Maintaining a Foreign Key Relationships
Attributes
Check table
(defaults to
value table)
Enter a description (short text).
Maintain cardinality n : m
Maintain foreign
key type
PricewaterhouseCoopers Slide 30
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.

PricewaterhouseCoopers
ABAP Dictionary Tables
in Relational Databases
SAP Table Types
Technical Settings
Indexes
PricewaterhouseCoopers
SAP Table Types
Transparent Table
(TRANSP)
Structure (INTTAB)
Pool Table Cluster Table
View
PricewaterhouseCoopers
Transparent Tables
Type = TRANSP
Master Data
PricewaterhouseCoopers
Table Types TRANSP
in the Database
DB
PROFILE
PricewaterhouseCoopers
Pool Tables: Overview
PricewaterhouseCoopers Slide 36
Cluster Tables : Overview
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
PricewaterhouseCoopers
Master data User data
Data Class
Organization and
Customizing data
Transaction data
DB
PricewaterhouseCoopers
Size Categories
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
PricewaterhouseCoopers
Maintaining Technical Settings
PricewaterhouseCoopers Slide 42
Table Logging
Transaction code : SCU3

PricewaterhouseCoopers
Table Index: Primary Index
PricewaterhouseCoopers Slide 44
Table Index: Secondary Index
PricewaterhouseCoopers
DB
Database Utility
PricewaterhouseCoopers
ABAP Dictionary Objects: Views
Definition
Relational operations
Types of views
Using a view in program code
PricewaterhouseCoopers
What is a View?
PricewaterhouseCoopers
The Most Basic Form of a View
PricewaterhouseCoopers
The Relational Operations
Table 2
Selection
View B
Table 1
Projection
View A
View C
Join
Table 4 Table 3
PricewaterhouseCoopers
The Projection Operation
Projection
View A
Table 1
PricewaterhouseCoopers Slide 51
Specifying Projected Fields
Can use any name if database view,
otherwise must be same name as table field.
Indicate actual table
Fields and data elements.
PricewaterhouseCoopers
The Selection Operation
Selection
View B
Table 2
Example:
Staff Level <= 3
PricewaterhouseCoopers
Specifying Selection Criteria
1 3
5
2
4
Can include unprojected fields
PricewaterhouseCoopers
The Join Operation
Table 3
Join
Table 4
View C
PricewaterhouseCoopers
Inner Join & Outer Join
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
Employee
Salary
Right
PricewaterhouseCoopers
The Join Operation and Foreign Keys
View C
Join
Table 4 Table 3
Primary Secondary
PricewaterhouseCoopers Slide 58
Specifying Joined Fields
Hit button to see related tables and
automatically generate join conditions.
Indicate base tables that data will come from.
PricewaterhouseCoopers
Types of Views in the ABAP
Dictionary
Database View
Projection View
Help View
Maintenance View
PricewaterhouseCoopers
The Database View
PricewaterhouseCoopers
The Projection View
PricewaterhouseCoopers
Help View
PricewaterhouseCoopers
Maintenance View
Transaction : SM30, SE54
PricewaterhouseCoopers
Using a View in Program Code
TABLES: YXXEMP_V.

SELECT *
FROM YXXEMP_V.

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

ENDSELECT.
PricewaterhouseCoopers Slide 65
Overview of Search Helps
Benefits of Search Helps
Elementary Search Helps
Collective Search Helps
Search Help Exits
PricewaterhouseCoopers Slide 66
The Benefits of Search Helps
What was Smiths
vendor number,
anyway?
F4
PricewaterhouseCoopers Slide 67
Elementary vs. Collective
Collective
Search Help
E
l
e
m
e
n
t
a
r
y

1
Field H
Field B
Field K
E
l
e
m
e
n
t
a
r
y

2
Field Z
Field O
E
l
e
m
e
n
t
a
r
y

3
Field A
E
l
e
m
e
n
t
a
r
y

4
Field R
Field X
Field B
Field O
Field Q
PricewaterhouseCoopers Slide 68
Creating an Elementary
Search Help

Create search help from Dictionary pushbutton on
workbench, or from within Repository Browser.
PricewaterhouseCoopers Slide 69
Defining an Elementary
Search Help
Optio
nal
exit
Hit List
Display
Method
Used to identify
search help
Data source
for hit list
Interface
Parameters
PricewaterhouseCoopers Slide 70
Defining an Elementary
Search Help - Interface Parameters
Parameters for values you
want to send and receive
Declaration of parameters
as import and/or export
Parameter is display only
Data element associated
with parameter
Position parameter
will be on hit list
Position parameter will
be on dialog box
Optional default
for parameter
PricewaterhouseCoopers Slide 71
Assigning an Elementary
Search Help - Priority Levels
Table
Data Element
Field
PricewaterhouseCoopers Slide 72
Using Elementary
Search Helps
F4
PricewaterhouseCoopers Slide 73
Defining a Collective Search Help - Interface
Notice there is no selection method. A
collective search help is a set of one or
more elementary search helps.
PricewaterhouseCoopers Slide 74
Defining a Collective Search Help -
Adding Elementary Search Helps
Dont forget to assign parameters
for each elementary search help.
PricewaterhouseCoopers Slide 75
Using a Collective Search Help
F4
Only difference from
Before - toggle tab between
elementary Search helps.
PricewaterhouseCoopers Slide 76
Lock Object
Naming Convention : Starts with E
Lock Object will generate 2 function modules:

ENQUEUE_<LOBJ.NAME>
DEQUEUE_<LOBJ.NAME>


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

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

PricewaterhouseCoopers Slide 78
Lock Object Details
PricewaterhouseCoopers Slide 79
Lock Objects Parameters

You might also like