ABAP Dictionary
Abstract
The following section details and describes the ABAP Dictionary.The
main purpose of this chapter is to show how to realize all the
development objects to be used in the future Web Dynpro
applications.Therefore,we present not only the modality to create the
various development objects in the ABAP Dictionary, but also the
modality to use them in realizing Web Dynpro applications.
We
can create development objects in ABAP Dictionary,by using the
transaction SE11(ABAP Dictionary Maintenance) or the Object Navigator.
Development object with transaction SE11
ABAP programming language has a number of ten elementary data types that we can use in our programs. When we want to create global data types by using the ABAP Dictionary, we have to use dictionary built-in types. These predefined types are different from the elementary data types. We need them for reasons of compatibility with the external data types.
In
this we presented some of the ABAP Dictionary Built-In types and a few
corresponding examples of Dictionary built-in data types and
ABAPelementary types.
Some of ABAP Dictionary Built-In types and corresponding ABAP elementary types
A data element defines an elementary data type and has certain properties. We create a data element YDATEOFBIRTH
Definition of a data element
In
the “Data Type” tab we can choose between the elementary type and
reference type. The elementary type can be a domain and a build-in type.
In this case, we have chosen the build-in type DATS that has a
predefined format (YYYYMMDD) and a predefined length 8.
In
the tab “Field Label”, we can set a field label that is automatically
shown in the label, or caption of an UI Element that is bound to an
attribute of this type.
For a data element, we can create documentation F1 Help with Goto -> Documentation -> Change.
This documentation is not seen on screen if the Web Dynpro application
attribute WDHIDEMOREFIELDHELPASDEFAULT was set as ABAP_TRUE. We create a
text that describes the content of our data element.
Creating a F1 help for a data element
A
domain defines a value range.To be able to use it in a Web Dynpro
application,in other repository object, as parameter in GUI
programming,etc.we have to assign it to a data element
Data elements and domains
We
create a domain named Y_COUNTRY_DOMAIN that holds all the names of EU
member states, with the proper abbreviation. In “Definition” tab we have
to specify properties as data type, number of characters or length of
output
Definition of a domain – tab “Definition”
In “Value Range” we have three possibilities:
- Single values
- Intervals
- Value table
We
begin with the first possibility, “Single values”. We define the domain
fixed values – all the abbreviations of the EU countries, and a short
text – the corresponding country names.
Definition of a domain – tab “Value Range”
As
we have specified, to be able to use a domain we have to assign it to a
data element. To do this, we create a new data element and we choose
the elementary type – domain.
Assigning a domain to a data element
When
we use this data element in our Web Dynpro application, for example to
define a parameter or a context attribute, the user is allowed to choose
only the values that range among values we have defined in Domain.
To
explain the next possibility (“Intervals”), we take an example where we
need to store, in a table column, the ages between 18 and 45. In this
case, we can use an interval to limit the values that the user may
enter.
Definition of a domain – interval
We use this interval in the database table YPERSON, defined hereinafter. For this, we assign it to a data element Y_DEINTERVAL.
To explain the last possibility (“Value Table”), we use a domain that is defined in the system: WAERS.
Domain WAERS – value table
It
is recommendable to use the value table when we have many fixed values.
In our case, we have used the system table TCURC. This table holds all
the system currency.
We
use this value table in the database table YEU_COUNTRIES, defined
hereunder. For this, we assign it to a data element Y_CURRENCY.
Structures
consist of any combination of other data types of the ABAP
Dictionary.In fig. we present a structure with three components:
FIRSTNAME, LASTNAME and DATEOFBIRTH.
Definition of a structure
For each component it is defined a component type, as follows: a data element,other structure, table type, etc.
As
a component type for a structure, we can choose a type that is already
defined in the ABAP Dictionary, or we can create a new type. For
example, the component DATEOFBIRTH has YDATEOFBIRTH data type. This data
type has been already defined.
If
we want to create a new type for a component, we have to enter its name
(for example, YFIRSTNAME) and then, with double-click, we can choose
the new type.
Creating a new component type
After
we create a structure, we have to maintain the enhancement category:
Extras ! Enhancement Category, from the menu. In case we don’t want to
further extend the component structure, we choose “Cannot be Enhanced”.
Maintaining enhancement category
We can use the structures defined in ABAP Dictionary to create the context node structure for a Web Dynpro application.
We create two transparent tables, YPERSON and YEU_COUNTRIES. We will use this table later, for our Web Dynpro example.
In
the YPERSON table, we want to store the competition candidates. All the
candidates should be 18–45 years old and live in an EU country. After
creating the table, we have to enter a short description along with the
delivery and maintenance
Table maintenance
We
set “Data Browser/Table View Main” ! Display/Maintenance Allowed, to be
able to populate our table with values, using “Create Entries”, from
the menu.
Then,
we will define our table structure. To do this, we select the tab
“Fields” and enter the table columns For the fields MANDT and ID_PERSON,
we have marked the option “Key”, meaning they are the table keys. The
field MANDT is the SAP client field, a three-character client ID. The
field “ID_PERSON” represents the candidate’s ID, required to uniquely
identify each competition candidate.
Table structure
As
can be seen, we have used the data elements created hereinbefore:
YFIRSTNAME, YLASTNAME, Y_DEINTERVAL, Y_DEFORDOMAIN. When we want to
create a new data element, we write its name and, with double-click, we
activate the forward navigation. If this data element doesn’t exist, we
are asked if we want to create the new data element.
Creating a data element
Before being able to activate this table, we have to maintain the technical settings
How to maintain the technical settings for the table YPERSON
We choose a size category 0, because we don’t require many data records. We have to maintain the enhancement category: Extras -> Enhancement Category,
from the Menu. We choose the same “Cannot be Enhanced”, because we
shouldn’t further extend the table structure. After this, we can
activate our table and create the second table YEU_COUNTRIES.
We
hold here all the EU Member states information, as follows: country
name, year of EU entry, political system, capital city, currency and the
flag image name. The structure of this table is presented.
Table structure
After
this, we have to define a foreign key for the field CHECK_CUR. For this
purpose, we use the button “Foreign Keys”. We are asked if we want to
use the value table TCURC as check table.
How to create foreign key
We need TCUC as a check table, because we want to use its table contents, respectively the Currency Codes.
Currency codes
After we maintain the Technical settings and enhancement category, we can activate the same as for the table YPERSON.
The candidates can live only in an EU country. Therefore, we create a 1 to CN relationship between the tables.
From the table YPERSON field ID_COUNTRY, we create a foreign key.
How to create a foreign key
The
system can generate the graphical representation of the relationships
we have defined between tables. To show this graph,we use the Button
“Graph”.
Foreign key relation ship
We can see our tables YEU_COUNTRIES, YPERSON and the 1:CN relationship.
The
table TCUC is the check table for the table YEU_COUNTRIES. To see this
relationship also, we have to select the name of YEU_COUNTRIES table and
to press the Button “Check Table”.
Foreign key relation ship
We can create contents withUtilities --> Table content --> Create Entries from Menu
Insert – table YEU_COUNTRIES
To display the content: Utilities --> Table content --> Display from Menu.
Select – table YEU_COUNTRIES
We
can use the transparent tables defined in the ABAP Dictionary to create
the context node structure for a Web Dynpro application.
ABAP
Dictionary offers the possibility to create simple search help and
collective search help. To create a search help, we can use the context
menu of our package.
Creating a development object in the ABAP Dictionary by using the Object Navigator
We create a simple search help YSH_ID_PERSON for the column ID_PERSON of the table YPERSON
Creating a simple search help
As
can be seen at Data collection ! Selection method, we have used the
table name YPERSON. This means that all the data required come from our
table YPERSON. A search help can have the following parameters: “import
parameters”, “export parameters” or “no import” and “no export”. We have
used ID_PERSON as export parameter, because we want its value to be
returned to the input template. LPos represents the parameter position
in the hit list: FIRSTNAME has the position 1 and it is firstly
displayed in the hit list, and LASTNAME has the position 2, being
displayed after the FIRSTNAME.
Testing a search help
Afterwards,
we want to use this search help in a Web Dynpro application. We create a
search option for a competitor. The user has to enter the competitor’s
ID into a search mask. The list of IDs is limited to the number of
competitors. When the user doesn’t know the competitor’s ID, he uses the
search help and can choose the competitor’s name. The content of the
ID_PERSON parameter is returned to the search mask as soon as the user
has selected a line of the hit list in the input help. In this way, we
facilitate the input.
We
can use this search help if we link it with the ID_PERSON column of the
YPERSON table. To do this, we select the column ID_PERSON and press the
button “Srch Help”.
Search Help for the field ID_PERSON
After we enter the search help name, we have to create the search help attachment, and to save and activate the table
How to create search help attachment to the column ID_PERSON
In
this way, we have created a simple search help for the column ID_PERSON
of the table YPERSON. When we use this column in Web Dynpro, the
Framework creates a special icon to be used at the runtime to call the
input help. Moreover, we can use the keyboard key F4 to call an input
help.
To
be able to access a search help from a WD component, the proper Input
Help Mode context attribute property has to be set (“Automatic” or
“Dictionary Search Help”).
By
using a view, we can combine the data distributed in several tables.
For a better understanding, we create a view on the tables YPERSON and
YEU_COUNTRIES. When we create a view, we can choose one of the four view
types.
View types
We
choose to create a database view named YVIEW_CMPETITION. At the
beginning of the “view definition”, we have to select the view base
table (in ourcase, the table YPERSON.After the base table definition, we
link this table by defining the joining conditions. To create this
link, we use the button “Relationships”.
Creating a view
Joining conditions
In
the next step, we have to select the fields we need in our view. We can
enter each field manually or we can use the Button “Table fields”.
View fields
After activation, we can see our view content using the “Contents Button”.
View content
In this way, we have created a database view on the tables YPERSON and YEU_COMPETITION.
View definition on the database
By
using this view, we can create the context node structure for our Web
Dynpro application and so we simultaneously select the logically
connected data, from two tables.
We create a table type named YTABLE_TYPE, the line type being our YPERSON table
Creating a table type
For
the line type, we can use an existing type (table, structure, view, . .
.) or we can enter the data type, length and number of decimals. The
typical use of table type is the declaration of an internal table.
Another
example of using table type is to populate with values a context node
via a supply function. To be able to do this, we create a table type
named YTABLE_ TYPE_STRUCTURE with the line type – the structure
YSTR_PERSON.
Table type – line type structure
In the next chapter, we show how we can use this table type to populate a context node.
We create a Lock Object for the database table YPERSON. The lock object name has to begin with the prefix E (from “Enqueue”).
Lock object
Our
case consists of exactly one table, and the lock argument is the
primary key of this table. The lock mode is set to write, but can be
overwritten.
After the lock object activation, the ABAP Dictionary generates two Function Modules, named ENQUEUE_ and DEQUEUE_.
The Function Modules with enqueue prefix help us to set a lock, and the
Function Modules with dequeue prefix help us to release the locks.
With
the SE37 transaction we can see the two generated Function Modules:
ENQUEUE_EYPERSON and DEQUEUE_EYPERSON. Figure shows the structure of the
Function Module required to set a lock.
Function Module for lock setting
SAP
offers a lock mechanism required to provide two transactions by
simultaneously changing the same data in the database. The lock table
represents a table in the memory of the enqueue server and is used to
manage all the locks in the system. This lock table is checked every
time when the enqueue server receives a lock request. A program sends,
to the lock table, the key of the table entries it wants to lock; if no
lock is set, the request is accepted and the new lock is written in the
lock table. If a lock is set, the request collides with an existing lock
and the request is rejected.
No comments:
Post a Comment