Friday, 5 April 2013

ABAP Dictionary

ABAP data object are stored at application server while the actual data resides at database server.


ABAP Data Dictionary is the Central source of data of SAP system OR ABAP dictionary is the central core component which supports the creation and management of all the data definitions used in the system. ABAP Dictionary is completely integrated with the ABAP development workbench and is active in the development and run-time environments of the SAP system. This ensures that any changes made in the data definitions results in subsequent changes in the all related ABAP programs, function modules, menu, screen painter or any other application where it has been used.  
The major object types in the Data Dictionary are Database tables, views, data type (data elements, structures, table types), domains, search helps and lock objects. The user can create, modify or delete the data definitions using the above objects.
Please note that ABAP Dictionary contains Metadata (Data about data) about the data stored in SAP R/3 system. Thus the definition of the ABAP data object are stored at application server while the actual data resides at database server. The main aim of ABAP Dictionary is to improve the system performance by minimizing the overall database hits and provide a layer of abstraction between the various layers of R/3 system.
To open ABAP Dictionary from the SAP Easy Access Menu Go-To Tools->ABAP Workbench->Development and then Double Click the ABAP Dictionary option listed.  Alternatively, you can do so by entering the transaction code for ABAP Dictionary SE11 in the command field. The transaction SE11 provides you with all the important objects of ABAP Dictionary. However there are other transactions fromSE13 to SE17 for specific purpose related to Dictionary view or modification.

ABAP Dictionary
ABAP Dictionary



The SAP R/3 system comes loaded with the basic business functionality usage data objects. However if you want you can create your own data objects as well. These are called as user defined types. But before creating any of user defined data objects ensure that the one you are creating is already provide by SAP or else you might end up duplicating the object and hence inefficiently utilizing SAP’s features.

A brief Introduction ABAP Dictionary Objects

  1.  Database Table- A table is multi dimensional matrix which is used to store data. There are 3 layers of data description of ABAP data dictionary which is to isolate the end users and even developers from the underlying database management system. The three layers of data description are:-
  •      External Layer – This is the end user view of the database. It mainly consists of how the user sees and interacts with the data. 
  •  ABAP Layer – The ABAP/4 layer describes the data formats used by the ABAP/4 processor. This is the developer’s/programmer’s view of the database. 
  • Database Layer – It is the DBA view of database. It describes the data formats used in the database.
In R/3 database there are two types of tables:- A. Client Dependent  B. Client Independent
  • Client Dependent- Database Tables with their first field name as 'MANDT' and type as 'CLNT' are client dependent tables.
  • Client Independent- All the tables with the first field name is not "MANDT' are client Independent, or in other words, all the tables which are not client dependent are client Independent.
The data in client dependent table is stored and retrieved based on the client number of the user. This is helpful in the scenario where we want developers and testers data to be different. 

Based on SAP R/3 system there are three types of tables: - A. Transparent Table, B. Pool table C. Cluster Table.
A-Transparent Table: - These tables have the same structure both in the ABAP dictionary as well as in the underlying Database.  It means that there is a one to one mapping between the two and the both the dictionary table and database table shares the same name, number of rows and columns. As we create a Transparent table in the Data Dictionary a similar structure table is created in the underlying database as well.
Transparent tables are mainly used to store application data which is basically the master data or transactional data of table. And mostly, transparent tables are the only one you will create as pooled and cluster tables are not used to store transaction data.
E.g.:- BKPF, VBAK, VBAP, KNA1, COEP etc
B- Pool Table: - A pool table means a pool of tables of the data dictionary representing a single database table. There is a many to one relationship between the data dictionary and database and the names of table in ABAP dictionary are different from the one in database.  Pool tables are used to store system data and system configuration. A Pool table is stored along with other pooled tables in database as table pool.
E.g. of Pool Table: - M_MTVMA, M_MTVMB

C- Cluster Table: - Cluster Tables are similar as the pool tables while the only difference between the two is that all the pool table stored in table pool does not need to have any foreign key relationship but in the case of cluster table it are must. Cluster tables can be used to store control data.  They can also be used to store temporary data or texts, such as documentation.
E.g.  Of cluster table BSEC, BSET, BSEG. 

 2.VIEW: - A VIEW in SAP is same as in other programming languages. A VIEW is a table with no contents. A view could also be representation of data from 2 or more logically related tables combined using joins or any other database operations. A View is mainly used to either display data from two or more tables or to project only selected fields of tables. We can use a view either separately (through SE11) or we can use it in any report we create (SE38) There are four types of Views in SAP: -

A.      Database View- A database view is the one which we create to display logically related data distributed among various tables.

B.      Projection view- A projection view is the one which we create to display only selected fields of a table. You cannot define any select conditions or joins in the projection view.

C.      Maintenance View- Maintenance like database view displays application data from multiple tables but the tables in maintenance view must be connected through foreign key relation.

D.      Help View- Help views are created to provide Input Help(F4) for any field in selection screen. Please Note that we can only use Help view if we need to retrieve data from tables combining them using Outer Join.

3.       Domain: - Domain defines the technical attributes of a field such as the data type, length and value range of field. For e.g. A Domain ‘ID’ is of data type ‘Integer’, length ‘4’ and value range 1 to 9999.  

4.       Data Elements: - Data elements define the semantic characteristics of a field. A data element contains field labels and Documentation (F1) of the field. A data element consists of a domain and the short description about the domain for which it is defined.
For e.g. A data element ‘Employee Id’ for employee table has a domain ‘ID’ defined and the short text defined as ‘Employee ID for employee of XYZ company’.

5.       Structure: - Structures are complex data types composed of multiple fields including data elements, table types or other structures. Structures are mainly used when we want to retrieve the records from database tables and alter them for modifying database or for displaying it to users.

6.       TYPE GROUPS – Suppose, we require a group of data types or 2 or more structures or both for more than one programs. Then instead of declaring them individually I each program we can create a type pool or type group of them. Type groups allows us to define the data types or structures in data dictionary.
Syntax:-


TYPE-POOL ZDEMO .

TYPES: BEGIN OF ZDEMO_ZTEST_5005874DEM ,
EMPID TYPE INT4,
EMPBRANCH TYPE C LENGTH 20,
NAME TYPE C LENGTH 20,
LNAME TYPE C LENGTH 20,
DEPTID TYPE INT4 ,

END OF ZDEMO_ZTEST_5005874DEM.

TYPES : BEGIN OF ZDEMO_ZTEST_505874TEST,
DEPTID TYPE INT4 ,
DEPTNAME TYPE C LENGTH 20,
END OF ZDEMO_ZTEST_505874TEST.

7.       Search help: - Search helps provides advanced input helps to user for selecting input fields based on the conditions used to create search helps.

8.       Lock Objects:- It implement application-level locking when changing data.

No comments:

Post a Comment