You are on page 1of 39

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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.

Creating a Structure in ABAP Dictionary ........................................................................ 30

4.

Serach Help .......................................................................................................................... 33


1. Elementary Search Help .................................................................................................... 33
2. Collective Search Help ...................................................................................................... 35

5.

Lock Object : ........................................................................................................................ 37

1|Page
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

1. Creation of Transparent Table:


Transaction:SE11
1.

2.

Enter the table name and press Create

Enter the description, Delivery class and check on table maintenance allowed. Then click on the tab Fields.

3|Page
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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.

Save it as a local object on pressing Local object button

4|Page
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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.

Then press Datatype tab and enter the domain.

9.

Double click on that ZEMPNO to create domain, then it will ask for save before going next screen.

5|Page
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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.

13. Then press Ctrl+F3 (Activate


Object.

) the Domain. It will ask for save before activation. Save it as a local

14. Press Enter.


15. You will get a message Object saved and activated. Press on back button.
(Now you are in Data Element Screen Again)

6|Page
ABAP Dictionary

Ram

SAP ABAP Materials

16. Press Ctrl+F3(Activate


on back button.

For Trainings contact ramdabap@gmail.com

) 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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

28. Press enter.


29. Now you will get the following screen. Press Back button.
30. Activate the data element by pressing Activate button or Pressing Ctrl+F3.
31. Press enter.
32. Press Back button. (Now you are in Table Screen)
33. Now we created two fields. And Data elements and Domain for these two fields.
Now we have to maintain the technical settings. Press on Technical settings button.
Press on Technical settings Button.
34. Give the data class and size category of the table as per the requirement.

And press the back button.


35. Now activate the table by pressing the activate button or CTRL+F3.
36. Press Enter
38. Now enter the data into table. Go to Utilities Table contents Create Entries.

8|Page
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

39. Now enter the data in the fields and Save it.

40. Press on Reset Button.


41. Enter the data for the second entry into the table.

9|Page
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

42. Save it and press reset.


By following the above procedure you can enter the records as many as you want. (Go Back)
47. To see the table contents go to Utilities Table contents Display. Or press Ctrl+Shift+F10.

48. You will get the following screen.

49. Press on run button or press F8. Now it will display the table contents.

10 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

Now we know how to create the table.

2. How to create a domain in SAP?


To create a domain go to t-code SE11.

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

In the popup window select the correct data type.

Enter the number of characters. Enter the decimal places if it applicable to data type that you have selected. Save and activate
the domain.

3. How to create a Data Element in SAP?


To create a data element go to t-code SE11.

Select the Data type radio button, enter the name of the data element and press create.

13 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

Select the Data Element radio button and press continue.

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

Enter the field labels, Save and activate the data element.

4. What are Primary Keys and Foreign Keys?


A primary key is a field or group of fields that uniquely identify a record in a table. Primary key fields cannot be NULL and
cannot contain duplicate values.
If you want to link two tables, then primary key of one table will be added to another table where primary key of first table will
be become the foreign key of second table.
Consider the following two tables.
DepartmentTable

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

SAP ABAP Materials


004

Raj

For Trainings contact ramdabap@gmail.com


Bangalore

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.

5. How to create a Foreign Key in SAP table?


The purpose of the foreign key is to validate the data that is being entered into a table by checking entries in a check table.
Foreign keys are checked by the front end user interface only and it is not checked if you issue a direct a SQL statement to
update the database.
Follow the steps given below to create a foreign key in SAP table.
Step 1: Open the table in Data Dictionary (SE11) for which you want to create a foreign key. Select the field for which you want
to create the foreign key and press Foreign Keys button.

Step 2: In the popup window enter the check table name and press Generate proposal button.

16 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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 View (SE11)

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 View ( SE54)

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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 View ( SE54 )

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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)

4. After giving table name click on Table fields button

20 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

5. Choose the fields which you want to be displayed in output and click copy

6. Now Save, Activate & execute it, output will be

21 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

6. Creating Database Views


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'.

23 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

2. Below pop up screen will be displayed. Select 'Database View' and press

button.

3. Below screen gets displayed, enter suitable short description.

24 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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

present at the bottom.

25 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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 tool bar. Then activate the view with

present in application tool bar. Once view got activated, press


displayed, do not enter any value, just execute it.

to see the contents. Below screen gets

28 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

3. Creating a Structure in ABAP Dictionary


Go to transaction SE11 and select the radio button Data type. Enter a structure name starting with Y or Z.

Press create button.


A pop-up screen appears with 3 different options. Select the radio button structure.

30 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

Provide the description and also components.

31 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

Then press SAVE, CHECK and ACTIVATE.


Structure Created Successfully.

32 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

4. Serach Help
1. Elementary Search Help
Goto SE11..

Press On Create Button.

Select Elementary SH.. Enter..

33 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

Save and Activate the SH..


Test :
Execute the SH..

Enter

34 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

ESH is Working
2. Collective Search Help
Goto SE11 give name as ZNANI_CSH

35 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

Here you can Include your Elementary Search helps.


Exeuter the SH.. and result is

36 | P a g e
ABAP Dictionary

Ram

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

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..

Save and Activate .. Lock Object is Created.


Whenever you activate the Lock object it will generate 2 function modules.
1. ENQUEUE_EZLOCKOBJECT1 - (EZLOCKOBJECT1 Is your Lock object name)
2. DEQUEUE_EZLOCKOBJECT1

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

SAP ABAP Materials


MANDT
KUNNR

For Trainings contact ramdabap@gmail.com

= 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.

Run Program : ZNEW_PROG1_1 And Output is Error.

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

SAP ABAP Materials

For Trainings contact ramdabap@gmail.com

39 | P a g e
ABAP Dictionary

Ram

You might also like