Professional Documents
Culture Documents
Database
Data
Dictionary
Database Utility
You can access the database utility using transaction code ‘SE14’.
Types of data stored in database
Following types of data is stored in database :
Master Data: Large amounts of data which do not change often. It is often
read, but rarely updated. An example of master data is the data contained in
an address file, such as the name, address and telephone number. (APPL0)
Transaction Data: Data with temporary lifecycle, not stored long. Frequently
updated. An example of transaction data is the goods in a warehouse, which
change
after each purchase order. (APPL1)
Organization and Customizing Data: Specified when the system is
configured and then not often changed. An example is the table with
country codes. (APPL2)
System Data: System data is the data used by the BASIS to store
Two further data classes, USER and USER1, are provided for the customer.
These are used to define user developments.
Types of data stored in database
SAP uses the term master data to refer to control
tables and the traditional files that are necessary to Master Transactional
run a business such as personnel files, general Data Data
ledger accounts, customer files, etc. There is a 1:1
correlation between the master data tables in the
Dictionary and the tables in the physical database.
For each master data table in the Dictionary, the
same master data table exists in the physical
database.
Commercial data or transaction data is another
SAP term used to refer to data created as a result
of performing SAP business transactions such as
creating: invoices, orders, production schedules,
purchase requisitions, stock transfers, etc.
Data dictionary Objects
Basic Objects of the ABAP Dictionary
The basic objects of the ABAP Dictionary are tables, data elements and domains.
Tables store the information that is in the database
Data elements and domains are used to describe the characteristics of fields.
Table A Table B Table C
Domain
Domain
Domains
Domains
A domain specifies the technical characteristics and the allowed values of a
table field.
The technical characteristics of a table field are the field’s type and length.
These are also referred to as the field’s format.
The allowed values of a table field define what is acceptable input for that
field. These may be listed explicitly or may be specified by reference to a
value table. The concept of allowed values is explained more fully on later
pages.
Creating a domain
Steps for creating a domain :
Go to transaction SE11.
Enter a name for a domain.
Click Create.
Creating Domain
January
February Value Table
March
..
..
..
.
December
Allowed Values
Fixed Values :
Valid values for a domain can be explicitly listed. To create or maintain an explicit list of valid values,
use the menu path Goto Fixed Values on the Change Domain screen in the ABAP Dictionary.
Explicit values are used when the list of valid values are not likely to change over time.
For example, if a domain was meant to contain the names of the months of the year, it would be
possible to explicitly list “JANUARY” through “DECEMBER” as the allowed values (note that this
would not work well in a multi-language environment)
Value table :
Valid values for a domain can also be specified by reference to a value table. When this is done, the
records in the value table specify the valid values for the domain. In order to specify a value table for a
domain, one of the key fields of that table must point to that domain. That field is the one that
determines the valid values for the domain.
A value table is used when the list of valid values may change over time.
For example, a car maker may want to use a value table to list the valid colors for certain car
models. As new colors are developed, the value table can be updated without changing the domain
itself.
Benefits of Using Allowed Values
By defining valid values for a domain, automatic validation is provided for any
fields that point to that domain
valid invalid
values values
Data Elements
Data Elements
A data element provides a meaningful description for a field.
SAP R/3 comes delivered with many pre-defined data elements
A data element defines the semantic attributes of a field.
Create Data Element
Steps to create data elements:
Go to transaction SE11.
data type.
Click Create.
DB
Data Class
Size Category
Buffering Type
Logging
Technical Settings
Technical settings allow you to optimize the storage requirements and
table access behavior of database tables.
Data class - Designates the table to an area in the physical
database where similar tables are grouped according to type of
data (Master, Transaction, etc.).
DB
Data Class defines the type of data which would be stored in the table.
Defining a data class has the effect of storing the table in a defined area
of the database when the table is created.
Size Categories
A table’s size category identifies the amount of disk space on the database that
is allocated to the table.
Size Categories
A table’s size category identifies the amount of
disk space on the database that is allocated to
the table.
If the number of records in a table exceeds the
original size category, then more space will
automatically be allocated in the database.
The storage space will be incremented by the
amount of the original size category.
Buffering Type
Single Record
Buffering is only recommended for tables with data that typically does
not change or get updated.
Full Buffering types:
Single record: Only a single record actually being processed is
moved into the buffer. This type of buffering preserves buffer space
but requires more database hits in order to load the table.
KF1 KF2 KF3 F4 F5 Recommended for large tables when only a few records need to be
accessed.
Generic: A subset of the table records are loaded based on part of
the primary key. Recommended if only certain “generic” areas of the
table will be needed.
Full: Results in either all of the table or none of it being loaded into
Generic the buffer. Recommended for a) tables up to 30 K in size, b) larger
tables where access is needed to many records, and c) tables
against which attempts to access data will frequently yield a “no
record found” result.
Logging
On the technical settings screen you can specify “Log data changes” to
automatically generate a log file of details on the structure of a table, a list of the
data changes made during a certain period, and statistics.
In addition to clicking the checkbox “Log data
changes” on the technical settings screen, you must
ensure that the System Administrator has also
specified the switch or entry to allow “Table Logging
On”.
Log files do not rely on successful database
updates to be completed before they are written.
The existing logs can be displayed with Transaction
code SCU3.
Index
To improve performance, SAP automatically creates a primary index (id 0) for
transparent tables based on the primary key. You can also define your own secondary
indexes for transparent tables.
Indexes accelerate the reading of tables when the system looks for records satisfying
specific select criteria. The system determines the most efficient index by which to
select data for the specific request.
An index serves as a sorted copy of the table reduced to specific fields, with a pointer
to the remaining fields.
Database indexes are defined in ABAP Dictionary and stored in the physical database.
Creating Secondary Indexes
Creating Secondary Indexes
From the ABAP table maintenance screen use the menu path GoTo Indexes.
A pop-up window appears. In pop up window press the create button and select
the entry ‘Create Index’ from the dropdown. Assign a 3-character id to your index.
Provide a short text and select the field(s) by which the table needs to be indexed.
Note :
Secondary index is used for the tables which are not frequently changed (Eg:
Master tables)
Creating an index on an SAP table requires a repair, but it will not get overwritten
with an upgrade.
In the cases where database accesses are necessary and appropriate, it is
imperative to perform those accesses as efficiently as possible. The single most
important method of optimizing a database access is by using an index.
Database Indexes
Employee Names Index Employees Table
Last
Last Name
Name First
First Name
Name Pointer
Pointer ID
ID Last
Last Name
Name First
First Name
Name Salary
Salary
Adams Anthony
Burrows Gerry
Furia Fred
Gregory Tim
Jones Jimmy
Peters Beth
Treske Carolin
Zelkova Zephyr
An index is a set of fields from a table that is sorted and then stored in a location separate from the
table itself. Each record in the index contains a pointer to matching record(s) in the actual database
table.
Primary Key And Foreign Key
Primary Key and Foreign Key
Certain fields in a table are specified as the
primary key of that table.
The primary key is that field or combination
of fields that uniquely identifies a row in
the table.
A foreign key is a field (or combination of
fields) that represents the primary
key of another table.
Prerequisites for Constructing Foreign Key
Relationships
The foreign key field and the primary key of the
check table must share the same domain.
Therefore, foreign keys provide an
additional data integrity check
beyond that which is provided by
the value table.
Foreign Keys: Key Terminology
The table containing the set of
Value Table
allowed values attached to a domain
Check table
Maintain foreign
key type
Maintain cardinality n : m
Foreign Key field types
The following types of foreign key field can be defined:
No key fields/candidates : The foreign key fields are neither primary
key fields of the foreign key table nor do they uniquely identify a
record of the foreign key table (key candidates). For this reason, the
foreign key fields do not (partially) identify the foreign key table.
Key fields/candidates : The foreign key fields are either primary key
fields of the foreign key table or they already uniquely identify a
record of the foreign key table (key candidates). The foreign key
fields therefore (partially) identify the foreign key table.
Key fields of a text table : The foreign key table is a text table for the
check table, that is the key of the foreign key table only differs from
the key of the check table in that it has an additional language key
field. This is a special case of the type Key fields/candidates.
Text Tables
You create text tables when you want to store explanatory text in several
languages.
It is not advisable to store such texts in your primary table.
You can make a text table that must comprise the key of the primary table.
Every text table must also have an additional language key field (field of
data type LANG).
Cardinality
When creating foreign key relationships, you should always specify the cardinality
of that relationship
n :m
1 1
C C
CN
Uses of Foreign Keys
Foreign keys are used for:
Maintaining data integrity
Providing additional texts in the online help system
We can view the table contents by choosing Display and we can create
table entries by choosing Maintain.
SM 30
Transaction code SM30 can be used to display and update table data.
The table maintenance screen is as shown below :
Creating transaction code for
Table Maintenance Generator
Creating transaction code for Table
Maintenance Generator
Step1 : Go to se93 and Provide transaction code Name and Click On Create
Creating transaction code for Table
Maintenance Generator
Step 2: Enter shot text and select Transaction with Parameters(Parameter Transaction)
Radio button and click on enter
Creating transaction code for Table
Maintenance Generator
Step 3 : Below screen is
displayed.
Enter the transaction text.
Creating transaction code for Table
Maintenance Generator
Step 4 : Enter Transaction as
"SM30" and select skip initial
screen check box.
Enter view name value as table
name and update will be ‘X’.
Click on Save button to create the
transaction.
You may access the table
maintenance generator using this
transaction set by you.
Table Maintenance Generator
Events
Creating Table Maintenance Generator Events
The table maintenance generator events are the events specified by SAP and
programmable as required while interacting with the table maintenance
generator.
To create events, go to the table from SE11,
Go to Menu bar Environment ------->Modification---->Events
Creating Table Maintenance Generator Events
Click On New Entries Click on F4. Following entries are displayed
Here you can observe that there are different types of TMG events available like before
saving the data, after saving the data, before deleting, after deleting , Creating a new entry
and others.
Creating Table Maintenance Generator Events
Click On the highlighted button to open editor for writing the code.
Creating Table Maintenance Generator Events
Write the code for the event and click On Save and Activate
Creating Table Maintenance Generator Events
When creating the entries the code written in the form and endform
for the CREATE_ENTRY event is executed.
e.g. : For the given example, the user name, date and Last changed
on are automatically filled-in as the entry is created in the table
maintenance generator.
Structures
Structures
Structure - A group of internal fields that
logically belong together.
A Structure consists of components (fields)
whose types are defined.
A component can have an elementary type, a
structured type, a table type or a reference
type.
Creating Structures in ABAP dictionary
Go to SE11.
Beside Data
type enter
structure name
and click
Create.
Creating Structures in ABAP dictionary
A pop-up
screen appears
with 3 different
options. Select
the radio
button
structure.
Creating Structures in ABAP dictionary
Enter short description and fields and activate the structure.
Using Structures in Table Types
Go to SE11.
Beside Data
type enter
table type
name and click
Create.
Using Structures in Table Types
A pop-up
screen appears
with 3 different
options. Select
the radio
button
Table type.
Using Structures in Table Types
The structure can be described here as line type of the table type. This table type can be
used to store records.
Including Structures in Tables
Groups of fields or individual fields can also be added to SAP delivered
tables using append structures, or customizing includes:
Customizing includes are provided in SAP tables and structures to
allow you to add fields to these structures/tables without modifying
the tables themselves.
Append structures allow you to add fields to SAP-provided structures
and transparent tables that were not provided for in the standard
version.
Creating Append Structure
Click on the Append Structure in database tables
or structures and provide the structure name to
be appended.
Creating Append Structure
Append structures are intended for additions not provided for in the
standard version of SAP tables via customizing includes. They are to be
used with SAP transparent tables or structures, not with customer tables.
An Append structure is a structure assigned to exactly one table.
However, a single table can have a number of append structures. It is
recommended to use only one append structure in a table.
The fields of the append structure must always start with ZZ or YY.
When an append structure is activated, its assigned table is also activated
with all of the append structure fields. When a table including an append
structure is activated, the append structure fields are found and added to
the table.
Append structures cannot be deleted.
Append structures cannot be used with tables containing fields of data
type VARC, LCHR, or LRAW because these data types must be the last field
in a table.
Summary
Customizing includes are provided in SAP tables and structures to allow
you to add fields to these structures/tables without modifying the tables
themselves.
View A View C
View B
Creating Views
• Go to SE11.
• Enter the view name in front of view and
click Create.
Creating Views
Go to SE11.
Enter the view name in front
of view and click Create.
Enter short description and select the view fields for the basis table(The table for
which the view is to be created).
Specifying Joined Fields
Indicate base tables that data will come from.
Join Conditions
1 2 3 4 5
Specifying Selection Criteria (contd.)
You specify selection criteria by building logical expressions that compare
specific fields of a table to hard-coded literal values.
(1 & 2) Specify the table and field on which the restricted selection
should take place. Any fields, including unprojected ones, can be
indicated.
(3) Specify the relational operator used to compare the field to the value.
You may use EQ, NE, LE, LT, GE, GT, LIKE, and NOT LIKE.
(4) Specify the comparison value. Comparison values must be text or
numeric literals. Text literals must be enclosed in single quotes.
(5) You can specify multiple selection criteria (one per line) and link them
using the logical operators AND and OR. Unlike elsewhere in SAP (and
most other systems), OR takes priority over AND. Also, OR operations
are only permitted between lines which refer to the same field.
Types of Views in the ABAP Dictionary
Database View
Projection View
Help View
Maintenance View
The Database View
The database view is the only type of view in SAP that is physically created at
the database level.
In other words, the underlying database system also directly recognizes the
view, apart from SAP. Therefore, database views must be created over
transparent tables.
With the database view, all three of the relational operations (projection,
selection, and join) can be used.
Database views can be buffered just like transparent tables. In the technical
settings you can decide whether to have buffering off, or on with type single
record, generic, or full.
The Projection View
The projection view is a logical view. In this context, the word “logical” means
that the view exists within the ABAP Dictionary but is not recognized by the
underlying database system.
Projection views must be defined over a single transparent table.
The only relational operation that is valid for a projection view is projection.
Projection View
View
C
Database vs. Projection Views
Projection View Database View
Maintenance View :
These views permit maintenance of base table data. Transactions SM30
and SE54 are provided for working with maintenance views.
Summary
Views are used to look into one or more tables. A view does not contain
data of its own.
The projection operation is used to narrow a view’s focus to certain fields
in a table.
The Selection Operation is used to narrow a view’s focus to certain records
in a table.
The Join Operation is used to combine information from multiple tables
into a single view.
Types of Views in the ABAP Dictionary are Database View, Projection View,
Help View & Maintenance View.
The syntax to reference a view in an ABAP program is the same syntax we
use to reference a table.
Type Groups
Type Groups
ABAP Editor
PROGRAM ABC.
ABAP Editor ABAP Editor
TYPE-POOLS . . . TYPE-POOLS . . .
Data E
l
Docum ement
e n ta t i
on
TYPE GROUP
ABAP Dictionary
Type Groups
Type groups are used for creating customer-defined data
types. These type groups are created in the ABAP Dictionary
and are available for use in all ABAP programs.
ABAP Editor
ABAP Program
Run-Time Selection Screen
Summary
Type groups are used for creating customer-defined data
types. These type groups are created in the ABAP Dictionary
and are available for use in all ABAP programs
All throughout SAP, users must enter values into screen fields. These requested
inputs often are numerical codes and ID’s, or abbreviations. Acceptable values might
not be immediately evident, or the user might have forgotten the necessary input.
A list of valid values will appear when you hit F4, even if a search help was not defined
for that field. These valid values come from the domain that is attached to the field.
If we invoke a search help, we will see its results, not those from the domain valid
values.
Whether a search help is available or not depends on whether the programmer has
attached one to the field.
Search helps can return more than just the original search field to the screen.
Using Search Helps
To see a list of customers
starting with ‘S’
4
Types of search helps
An elementary search help is exactly one combination of fields that will
be used to determine the needed value.
F4
Used to scroll
the tabs for
Elementary
Search Helps
Individual Elementary Search Helps that
make up the Collective Search Help
Like with most objects in the Dictionary, you can also decide to make a
search help at any point while in the Repository Browser. It will assume
you want to save your object under the development class you are
browsing at the time.
Defining an Elementary Search Help
List Display
method
Used to identify
Optional
search help
Exit
Interface
Parameters
Defining an Elementary Search Help
The following are new terms you will see when you define your search help:
Hot key (optional) - Use this number to code values for the complex dialog box all in the
original search field.
Selection method - The name of the table or view that holds the data that will form your
help hit list. The fields from this table/view will be used in the interface parameters.
Text table - If there is a text table available for your main Selection Method table, it will
appear here. You can then use its fields as well in defining your search help path.
Search help exit (optional) - A function module that enhances the typical processing of the
search help. Not commonly used.
Dialog Type - Controls how you see your results.
The options are:
D - immediate hit list of valid values
C - dialog box where you can narrow down your search, followed by the hit list
A - if there are less than 100 matches, acts like D, if more than 100 matches, acts like C
The interface parameters are covered in more detail on the next slide.
Defining an Elementary Search Help –
Interface Parameters
Parameters for values you Parameter is display only
want to send and receive
Field
Table
Data Element
Assigning an Elementary Search Help -
Priority Levels
There are three different points where you can attach a search help. You can
assign a search help to all of them if you choose. When the user hits F4, the
system checks to see if there is a search help attached to the:
Field - To attach a search help to a field, click on the field in the table (or
structure) definition, and go to Goto Search help For field. This is the first
type of search help that is checked for, if one is not found, the system checks if
a search help is attached to the table.
Table - To attach a search help to a table, go to Goto Search help For
table. This is the second type of search help that is checked for, if one is not
found, the system checks if a search help is attached to the data element.
Data element - To attach a search help to a data element, double click on the
data element to get to its definition. Here you will find fields for specifying the
name of the Search Help and the Search Help Parameter. This is the third type
of search help that is checked for, if one is not found, the system does not use
a search help, but will check the domain for valid values. If none exist, then no
help is provided.
Defining a Collective Search Help - Interface
There are two parts to maintain in the collective search help definition, the Interface
section, and the Search helps section.
Since the collective search help is meant to be a collection of elementary search helps, you
should use the parameters section to declare all export parameters from all of the
individual elementary search helps.
Defining a Collective Search Help -Adding
Elementary Search Helps