Professional Documents
Culture Documents
Data Dictionary in Sap Abap
Data Dictionary in Sap Abap
CONTENTS
In Next lessons we will learn how to create tables, data elements, domains and
other data dictionary objects. Navigation: T-code : SE11
DATA TYPES DOMAINS DATA ELEMENTS IN SAP
ABAP uses different types of Data Types for Objects, basically there are three
types of data types Elementary Data types, Complex Types, Reference Types .
In Elementary types there are again two types of data types (Categories) Fixed
Length and Variable Length .
Fixed Length:
● C Text Field
● N Numeric
● D Date
● T Time
● H Hexadecimal
● P Parked Number
● I Integer
● F Float
Variable Length
● STRING Character Sequence
● XSTRING Byte Sequence
(We all know that table is a collection of fields, ex: STUDENT is a table with
fields STUDENT_ID, STUDENT_NAME ext, data element specifies the field
labels and headings for these fields )
Activate.
Domain is created.
Enter short description and domain name (ZSAPN_DOMAIN) and select field
label tab.
Select field label tab and maintain field labels.
Data entered should be checked against existing data to ensure that there are
now contradiction. While defining foreign key relationship cardinality has to be
specified. Cardinality mentions how many dependent records or how referenced
records are possible.
0 0 - 7,100
1 7,100 - 28,000
2 28,000 - 1,10,000
There are three types of database tables available in SAP, explained below
Transparent table
There is a physical table on the database for each transparent table. The names
of the physical tables and the logical table definition in the ABAP/4 Dictionary
correspond.
All business data and application data are stored in transparent tables.
Pooled table
Pooled tables can be used to store control data (e.g. screen sequences, program
parameters or temporary data). Several pooled tables can be combined to form a
table pool. The table pool corresponds to a physical table on the database in
which all the records of the allocated pooled tables are stored.
Cluster table
Cluster tables contain continuous text, for example, documentation. Several
cluster tables can be combined to form a table cluster. Several logical lines of
different tables are combined to form a physical record in this table type.
A table can be created in two ways, one is top to bottom approach and another
one is bottom to top approach.
Top to Bottom:
In this approach, first table fields are defined and later domain and data element
are defined.
Bottom to Top:
In this approach, first domain and data element are defined and later table will
be created.
In this example we are going to learn creating an SAP transparent table using a
top to bottom approach (I suggest a simplest way).
A table must contain at least one key field, without a key field we can not create
a table.
Double click on data element ZSTUDENT_NO (Not yet created), a pop up will
open, click yes and one more information message will come press enter.
Now a pop up will come asking to create date element, click yes.
Structure
The structure is a list of fields defined under a name, which is used to process
data at run-time in SAP ABAP applications.
Structures are two types one is global structure and another one is local
structure. Local structure can be created in ABAP programs and global structure
can be created in the data dictionary and can be reusable in different objects.
The structure is created, now we can use this structure in our ABAP programs.
HOW TO CREATE TABLE TYPE IN SAP ABAP
For the above requirement we need to create a class method to get details of a
material for a material input, for this method the importing parameter is material
no (to pass material input to method) and exporting parameter is of type
MARA(work area one material no contains only one record in MARA).Go to
SE24, provide class name as ZCL_SAPN_MATERIALS.
Provide description, save.
Double click on CODE icon or Go back to methods and double click on method
name and add below code.
*Select material data from mara table into exporting parameter ex_mara (work
Click on execute.
You will get material details for that material, now class with method is created
we have to use it in our program.
START-OF-SELECTION.
CALL METHOD LO_MATERIAL->GET_MATERIAL_DTAILS
EXPORTING
IM_MATNR = P_MATNR
IMPORTING
EX_MARA = WA_MARA.
WRITE :/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MEINS.
START-OF-SELECTION.
CALL METHOD LO_MATERIALS->GET_MATERIALS_FOR_TYPE "call method to
get materials
EXPORTING
IM_MTART = P_MTART
IMPORTING
ET_MARA = IT_MARA.
Program input.
Program output.
Table Structure
Tables will store data physically and Structure can not store data physically, it
permanently. can hold data at run time only.
Tables have primary keys. Structure's does not have any primary
key.
Table have technical settings (data class, Structure's does not have any technical
size category, etc), maintenance attributes and maintenance attributes.
attributes (Display maintenance
restrictions).
Table have primary and secondary Structures does not have primary and
indexes. secondary indexes.
The below are the major differences between transparent, pooled and cluster
tables in SAP data dictionary.
Transparent Tables Pool Tables Cluster Tables
Contain a single table. Used They are used to hold a large They are used to hold data
to store master data number of very small from a few number of
tables(stores system data). large tables.(stores system
data).
For each transparent table It is stored with other pooled Many cluster tables are
there is one associated table tables in a single table called stored in a single table in
in the database. table pool in the database. the database called a table
cluster .
The database table has the The database table has The database table has
same name, same number of different name, different different name, different
fields and the fields have number of fields and fields number of fields and
the same names . have different names. fields have different
names.
There is only a single table . Table pools contain more Contains less tables than
tables than table clusters . table pools .
1. Field Level validations: We can validate entries at field level with the help of
check table concept.
2. Domain level validations: We can restrict entries at the domain level with the
help of fixed values of the domain and value table of the domain.
Click on technical settings button and provide data class and size category.
Go to utilities- table contents - create entries add some entries to the table.
Go to tab Entry help/check, select city fields and click on 'Foreign key' icon.
Provide short text, check table name ZSTUDENT_CHECK and click on
'Generate Proposal' and click on copy.
Save and activate the table(If you get a warning popup when activating just
press no).
Now go to utilities - table entries -> create entries
Provide a city name which is not in ZSTUDENT_CHECK table and try to save,
it will trough an error.
FIXED VALUES OF A DOMAIN IN SAP
SAP Table screen entries can be restricted using domain fixed values, we can
maintain domain fixed values at domain level when creating a domain.
Create domain with fixed values.
Provide short description, data type and length as below and click on value
range tab.
Database View
Introduction
Database views are used to combine application data often distributed over
several tables. The structure of such views is defined by specifying the tables
and fields that are required. Fields which are not required can be hidden,
thereby minimizing the interfaces. A view can be used in ABAP programs for
data selection.
Following demo shows how to create database view for two database tables
having foreign key relationship.
We will be creating a database view for below shown tables YZ14_BANK &
YZ14_ACCOUNTS. Note that YZ14_ACCOUNTS is foreign key table
(dependent table) and YZ14_BANK is check table (referenced table) for field
BRANCH_ID. It should be kept in the mind that we can only include
transparent tables in database view.
Steps
1. Go to transaction SE11 -> select radio button 'View' -> enter the name of
the view -> press 'Create'.
2. Below pop up screen will be displayed. Select 'Database View' and press
button.
7. On clicking copy button, join condition will be derived from the base
tables. In our case, we have the below shown conditions.
8. In the 'View Flds' tab, we need to enter all the fields, we want in our view
from the database tables. We can either enter the fields directly or we can copy
them from base tables. Later can be achieved by pressing
button present in the tab 'View Flds'. We can also include complete table in a
view by entering * in 'View field' & table name in 'Table'. If fields are inserted
or deleted from this table, similar modification will be automatically made in
view structure.
11. In above steps do not include 'MANDT' & 'BRANCH_ID' twice. While
activating the view, it will lead to an error.
12. As shown, we have the below fields in our view.
13. We can also formulate the selection criteria using 'Selection Conditions'
tab likewise coded below. Here we have entered the condition for account type
and status. All the data in the base table satisfying the below condition will be
selected based on other condition present.
14. Now save the view by pressing button present in standard toolbar.
Then activate the view with present in application tool bar. Once view got
activated, press to see the contents. Below screen gets displayed, do not
enter any value, just execute it.
15. Because of the condition we have put on acc_typ & status fields, entries in
the base table got filtered. We can see that all the entries have account type as
'CURRENT' & status as 'X'.
Summary
Above steps demonstrate how to create database view from multiple tables
having foreign key relationships.
Projection View
We use projection view to mask unwanted fields and display only relevant
fields in a table. Basically View acts like a database table only, the difference is
view will not occupy storage space.
Maintenance View
Go to SE11 transaction enter the view name
Go to SM30 transaction and enter the view name and maintain the entries.
Help View
Introduction: This document deals with a very basic topic of Help View and
step by step procedure to create it and use it in the search help. This document is
useful for beginners who want to learn how to create help view.
What is Help View: Help view can be used in the search help as in the
‘Selection Method’. We can also provide database table or database view name
there, but suppose if we want to get data as outer join then Help View can be
provided. It uses left outer join to select the data while database view uses inner
join. What it means: suppose I have two tables A and B. In help view all the
contents of primary table will be displayed.
And also if we want to show only particular data then in the ‘Selection
Conditions’ tab of the help view, we can also provide condition to select data.
Steps: 1) How to create Help View-
i) Go to transaction SE11
ii) Give View Name that you want to create
iii) Click on create button
iv) Now next screen appears with multiple options choose ‘Help View’
and click ‘Copy’
v) Provide short description and enter the base table name in the tables
field as in below screenshot then click on ‘Relationship’ button
On clicking of relationship button, it lists all the tables that are directly linked
with the base table that we have provided.
vi) Now select the table from the list and click copy. Join condition is
populated automatically.
vii) In the view field we put the fields that we want to show in our view.
Click on Table fields and select the table and fields.
Choose the fields that we want to include
viii) Now in the ‘Selection Conditions’ tab give the selection criteria if we
want to filter on the basis of some conditions as in below screen shot
For example if we want to include only those values for which “Company code
is 1000’ and ‘Item number is ‘010’ “
ii) In next pop-up choose Elementary search help. In the next screen
provide short description and in the selection method input provide the name of
help view. In the parameter, provide the search help parameters and provide the
other properties whether it is import or export parameter their positions etc.
Now Save and activate the search help.
3. Use of search help: we can use this search help with the help of keyword
‘Matchcode object’
Now at the selection screen when we press ‘F4’ in the select-option parameter
‘so_werks’ a list appears for which item is ‘10’ as we had given in our help
view selection condition
Summary: In the above example, steps for creating help view and how to use
that in search help has been explained.
4) A collective search help combines several elementary search helps. The user
can thus choose one of several alternative search paths with collective search
help.
6) Both elementary search helps and other search helps can be included in a
collective search help. If other collective search helps are contained in collective
search help, they are expanded to the level of the elementary search helps when
the input help is called.
Lock objects are data dictionary objects, can be created in SE11, follow below
steps to create lock object.
Example: Here I am creating a lock object to insert, delete, update for table
ZSTUDENT table in SAP.
Provide short description, select tables tab, provide table name and lock mode,
save and activate.
When ever we create a lock object two function modules will be created, go to
SE37, check FM`s DEQUEUE_EZSTUDENT and ENQUEUE_EZSTUDENT.
Using the lock object to update/insert table
When ever we create a lock object, two function modules(ENQUEUE and
DEQUEUE) will be created, we have to call those function modules before and
after open SQL statements, refer program below.
REPORT ZSAN_LOCKOBJECT.
WA_STUDENT-STUDENTID = '09'.
WA_STUDENT-NAME = 'SAPNuts'.
WA_STUDENT-LASTNAME = 'SAPNuts'.
WA_STUDENT-FATHER = 'SAP'.
WA_STUDENT-DOB = '25/09/2013'.
WA_STUDENT-GENDER = 'Male'.
WA_STUDENT-COURSE = 'SAP ABAP'.
WA_STUDENT-EMAIL = 'admin@sapnuts.com'.
WA_STUDENT-FEE = '0000'.
Lock Objects
Lock objects are used to synchronize the multiple set of users who are accessing
the same set of data.
Exclusive Lock
The locked data can be read or proceed one user only. A request for another
exclusive lock for a shared lock is rejected.
Shared Lock
Several users can read the same data at the same time, but as same as a user
edits the data,a second user can not longer access this data. Requests for further
shared locks are accepted, but exclusive locks are rejected.
All custom objects in SAP starts with Y or Z except lock objects.Lock objects
starts with EZ or EY.
Go To SE11 T-code.
Press Enter.
Provide the short description, the selection method.
Provide the fields.
Save it, Check It & Activate it.
Then execute it.
We can see the screen like this, and then press F4 in this page.
Then press F4 View the output like this.