Professional Documents
Culture Documents
Contents
1.
Tables: ..................................................................................................................................... 2
1. Creation of Transparent Table: ............................................................................................ 3
2. How to create a domain in SAP? ....................................................................................... 11
3. How to create a Data Element in SAP? ............................................................................. 13
4. What are Primary Keys and Foreign Keys? ....................................................................... 15
5. How to create a Foreign Key in SAP table? ...................................................................... 16
2.
VIEW: ................................................................................................................................... 18
1. Projection View ................................................................................................................. 18
2. Database View ................................................................................................................... 18
3. Maintenance View ............................................................................................................. 18
4. Help View .......................................................................................................................... 18
5. Creating a projection view:-............................................................................................... 19
6. Creating Database Views ...................................................................................................... 23
3.
4.
5.
1|Page
ABAP Dictionary
Ram
Data Dictionary
1. Tables:
Store the data base permanently until deleted. These tables are classified into 3 types
1.) Transparent Table
2.) Pooled Table
3.) Clustered Table
Transparent Table: Exists with the same structure both in dictionary as well as in database exactly with the same data
and fields.
Pooled Table: Pooled tables are logical tables that must be assigned to a table pool when they are defined. Pooled
tables are used to store control data. Several pooled tables can be combined in a table pool. The data of these pooled
tables are then sorted in a common table in the database.
Example: All Condition tables i.e., Annn tables (pricing/discounts etc.,) belong to the table Pool KAPOL (Condition Pool)
as the underlying concept is same across different condition tables, but, they have different Key (primary) fields.
Cluster Table: Cluster tables are logical tables that must be assigned to a table cluster when they are defined. Cluster
tables can be used to store control data. They can also be used to store temporary data or texts, such as documentation.
Example: Accounting Document Segment (Line Item records) BSEG is a cluster table that belongs to the table cluster
RFBLG. Also, other tables such as BSEC, BSED, BSES, BSET also come under the same table cluster as all of them possess
the common Key i.e., BUKRS/BELNR/GJAHR. And CDPOS (CDCLS)
BSEC - One-Time Account Data Document Segment, BSED- bill of exchange Fields Document Segment
BSEG-Accounting Document Segment, BSES-Document Control Data, BSET-Tax Data Document
Segment
Domain: A domain describes the technical attributes of a field, such as the data type or the number of positions in
a field. The domain defines primarily a value range describing the valid data values for the fields referring to this
domain.
Different technical fields of the same type can be combined in a domain. Fields referring to the same domain are
changed at the same time when a domain is changed. This ensures the consistency of these fields.
Data elements : (elementary types)
Elementary types have no structure. They describe the data type attributes (such as given Dictionary data type,
number of places) and information that is relevant for the screen (such as
title) of unstructured data objects (variables/fields).
2|Page
ABAP Dictionary
Ram
2.
Enter the description, Delivery class and check on table maintenance allowed. Then click on the tab Fields.
3|Page
ABAP Dictionary
Ram
3.
Enter the EMPNO in fields tab and ZEMPNO in field type tab.
4.
Double click on ZEMPNO. Then it will ask for Save. Press YES.
5.
4|Page
ABAP Dictionary
Ram
6.
Now it will ask for the creation of the data element. Press Yes.
7.
Click on the Field label tab and enter the lengths and descriptions accordingly.
8.
9.
Double click on that ZEMPNO to create domain, then it will ask for save before going next screen.
5|Page
ABAP Dictionary
Ram
Press Yes.
10. Save it as a local object.
11. Now it will ask for domain creation. Press Yes.
12. Give short description for that domain which you are creating. And mention the data type in data type
field and length in no. characters field and press ENTER.
) the Domain. It will ask for save before activation. Save it as a local
6|Page
ABAP Dictionary
Ram
) the Data Element.You will get a message Object saved and activated. Press
17. You will get the following screen.(Now you are in Table Screen)
18. Create one more field EMPNAME and give data element name as ZEMPNAME. And double click
onZEMPNAME ( You can follow the screenshots above to create Data Element and Domain)
19. Save it by pressing Yes.
20. Now it will ask or the data element creation. Press Yes.
21. Give short description of the data element. And give the lengths and field labels accordingly in Field label
tab.
22. Press on Datatype tab and give the domain name in Domain field. Double click on ZEMPNAME
23. It will ask for save. Press Yes.
24. Save it as a local Object.
25. Now it asks for Domain creation. Press Yes.
26. Give short description in short text field. Enter the data type and no. characters, Press Enter.
Then Press on Activate button or Press Ctrl+F3.
27. Save this as a local object.
7|Page
ABAP Dictionary
Ram
8|Page
ABAP Dictionary
Ram
39. Now enter the data in the fields and Save it.
9|Page
ABAP Dictionary
Ram
49. Press on run button or press F8. Now it will display the table contents.
10 | P a g e
ABAP Dictionary
Ram
Select the Domain radio button, enter the the name of the domain that you want to create and press create.
11 | P a g e
ABAP Dictionary
Ram
Enter
the short description. Place the cursor in the data type and press F4 to get the list of SAP data types.
12 | P a g e
ABAP Dictionary
Ram
Enter the number of characters. Enter the decimal places if it applicable to data type that you have selected. Save and activate
the domain.
Select the Data type radio button, enter the name of the data element and press create.
13 | P a g e
ABAP Dictionary
Ram
Enter short description. Assign a domain to the data element. Press field label tab to maintain the field labels for the data
element.
14 | P a g e
ABAP Dictionary
Ram
Enter the field labels, Save and activate the data element.
DEPARTMENT_ID
(PRIMARY KEY)
DEPARTMENT_NAME
01
Computers
02
Physics
03
Electronics
Employee Table
EMPLOYEE_ID
(PRIMARY KEY)
NAME
PLACE
001
Jim
New York
002
Jack
London
003
Robin
Sydney
004
Raj
Bangalore
If you want to link department table and employee table, then add the primary key of department table i.e. Department_ID to
employee table. Department_ID becomes the foreign key of employee table and Department table becomes the check table.
Employee table after creating foreign key.
EMPLOYEE_ID
(PRIMARY
KEY)
NAME
PLACE
DEPARTMENT_ID
(FOREIGN KEY)
001
Jim
New York
01
002
Jack
London
01
003
Robin
Sydney
02
15 | P a g e
ABAP Dictionary
Ram
Raj
03
The main purpose of the foreign key is data validation. This will not allow entering a Department_ID in the employee table that
is not there in the department table. For example if you try to create a record in employee table with Department_ID as 04, it
will throw an error.
Step 2: In the popup window enter the check table name and press Generate proposal button.
16 | P a g e
ABAP Dictionary
Ram
Step 3: The system proposes the foreign key relation based on the domain. Check that the foreign key relationship proposed by
the system is correct and press copy.
Foreign key is created, now save and activate the table. To check the foreign key go to menu path Utilities->Table Contents>Create Entries.
Try to create an entry in Zemployee table with Department ID that is not there in the Department table. Enter the values
and try to save the entry.
17 | P a g e
ABAP Dictionary
Ram
Observe the error message in the status bar. The user interface does the foreign key validation before creating the entries.
2. VIEW:
Is a imaginary database which does not really exist
1. Projection View
2. Database View
3. Maintenance View
4. Help View
Database views are implement an inner join, that is, only records of the primary table (selected
via the join operation) for which the corresponding records of the secondary tables also exist
are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a
reduced selection set.
In database views, the join conditions can be formulated using equality relationships between
any base fields. In the other types of view, they must be taken from existing foreign keys. That
is, tables can only be collected in a maintenance or help view if they are linked to one another
via foreign keys.
Help views are used to output additional information when the online help system is called.
When the F4 button is pressed for a screen field, a check is first made on whether a matchcode
is defined for this field. If this is not the case, the help view is displayed in which the check table
of the field is the primary table. Thus, for each table no more than one help view can be
created, that is, a table can only be primary table in at most one help view.
Projection View
18 | P a g e
ABAP Dictionary
Ram
Projection views are used to suppress or mask certain fields in a table (projection), thus
minimizing the number of interfaces. This means that only the data that is actually required is
exchanged when the database is accessed.
A projection view can draw upon only one table. Selection conditions cannot be specified for
projection views.
Maintenance views enable a business-oriented approach to looking at data, while at the same
time, making it possible to maintain the data involved. Data from several tables can be
summarized in a maintenance view and maintained collectively via this view. That is, the data is
entered via the view and then distributed to the underlying tables by the system.
5. Creating a 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.
1. Creating Projection View
19 | P a g e
ABAP Dictionary
Ram
2. Choose Projection View in the pop up which appears when you click on create
3. Give Description & base Table name(In this example we have taken KNA1)
20 | P a g e
ABAP Dictionary
Ram
5. Choose the fields which you want to be displayed in output and click copy
21 | P a g e
ABAP Dictionary
Ram
Summary
In standard SAP tables we will have many fields, of which we will use only few fields. whenever we go and view the
data we have to come across unwanted data, to avoid this and get display of field which relevant to scenario we
use this projection view.
22 | P a g e
ABAP Dictionary
Ram
Steps
1. Go to transaction SE11 -> select radio button 'View' -> enter the name of the view -> press 'Create'.
23 | P a g e
ABAP Dictionary
Ram
2. Below pop up screen will be displayed. Select 'Database View' and press
button.
24 | P a g e
ABAP Dictionary
Ram
4. In 'Tables' enter the name of the base tables which we want to include in our view. In this case we will be
entering tables as YZ14_BANK & YZ14_ACCOUNTS.
5. Next, we need to link the entered tables by specifying the fields in join condition. We can also derive the join
conditions from existing foreign keys between the base tables of the view. To do this, position the cursor on
the table names and click on
25 | P a g e
ABAP Dictionary
Ram
6. Below pop up comes wherein linked tables are present. Select the tables and press 'Copy'.
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.
26 | P a g e
ABAP Dictionary
Ram
9. On pressing 'Table fields' button we get a popup likewise shown below. Choose the table whose fields we want
to include in our view. Another popup will be shown select the fields we want to include and press 'Copy'.
10. We repeat the above step to include below shown fields from table YZ14_ACCOUNTS.
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.
27 | P a g e
ABAP Dictionary
Ram
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.
button present in standard tool bar. Then activate the view with
28 | P a g e
ABAP Dictionary
Ram
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.
29 | P a g e
ABAP Dictionary
Ram
30 | P a g e
ABAP Dictionary
Ram
31 | P a g e
ABAP Dictionary
Ram
32 | P a g e
ABAP Dictionary
Ram
4. Serach Help
1. Elementary Search Help
Goto SE11..
33 | P a g e
ABAP Dictionary
Ram
Enter
34 | P a g e
ABAP Dictionary
Ram
ESH is Working
2. Collective Search Help
Goto SE11 give name as ZNANI_CSH
35 | P a g e
ABAP Dictionary
Ram
36 | P a g e
ABAP Dictionary
Ram
5. Lock Object :
Goto SE11 :
Give table name of records which you want to lock and select any lock mode.. here Exculsive,
not cumulataive
Then Goto Lock parameter tab..
Test :
Create a program in SE38.
REPORT ZNEW_PROG1.
CALL FUNCTION 'ENQUEUE_EZLOCKOBJECT1'
EXPORTING
MODE_KNA1
= 'X'
37 | P a g e
ABAP Dictionary
Ram
= SY-MANDT
= '1000'
WRITE : LOCKED.
Copy Same Program into one more program with name ZNEW_PROG1_1
Create a one more program in SE38..
Write the Below Code :
REPORT ZNEW_PROG2.
CALL FUNCTION 'DEQUEUE_EZLOCKOBJECT1'
EXPORTING
MODE_KNA1
= 'X'
MANDT
= SY-MANDT
KUNNR
= '1000'
.
WRITE : 'unlocked'.
Test 1 :
Run Program: ZNEW_PROG1 and Output is Locked.
Test2 :
Write the Code of ZNEW_PROG2 under the code of ZNEW_PROG1 and execute.. Output is
Locked, Unlocked.
Then Run ZNEW_PROG1_1 output is Locked.
38 | P a g e
ABAP Dictionary
Ram
39 | P a g e
ABAP Dictionary
Ram