5

Getting Started with ABAP: How to Create View Part 2

 2 years ago
source link: https://blogs.sap.com/2022/06/23/getting-started-with-abap-how-to-create-view-part-2/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
June 23, 2022 3 minute read

Getting Started with ABAP: How to Create View Part 2

This is the next blog post in this series. Here is the previous blog post Getting Started with ABAP: How to Create View Part 1

In the previous blog post, we learned how to create database view on single database table.

In this blog post we will learn how to create database view on two tables.

How to Create Database View on more than one table

If you create database view on more than one table then you can only read the data through database view.

Step 1: Go to SE11. Select View and enter view name that you want to create.

1-99.png

Step 2: Click on Create. Select Database View.

2-37.png

Step 3: Enter short description.

3-32.png

Step 4: Here I want data from two tables hence I need to join two tables here. So, enter both tables name in Table column.

I have two tables one is employee table (ZAKTABLE) and second one is department table (ZAK_DEP).

My tables are:

ZAKTABLE

4-35.png

ZAK_DEP

5-29.png

First, I entered one table.

6-33.png

Step 5: Click on Relationships.

7-31.png

Step 6: You will get the name of second table. Select that table. You can see that join condition will get added. Join condition means in both table employee id field is common so based on that field we will join this two tables.

8-28.png

Step 7: Select View Fields tab.

9-29.png

Step 8: Click on Table Fields.

10-22.png

Step 9: Select first table name. Then you will get below window.

11-21.png

Step 10: Select fields from table that you want in result set. Here I selected 3 fields. And click on copy.

Note: You have to select all key fields from the table. Otherwise you will get error stating that key field is missing.

12-19.png

Step 11: You will get below window. Click on Table Fields.

13-19.png

Step 12: Select fields from second table. Here I selected 3 fields. MANDT and EMPLOYEE_ID fields are already selected hence no need to select it again.

14-14.png

Step 13: Click on Copy.

15-13.png

Step 14: In selection condition you can put condition that you can see in previous post.

In Maint.Status you can see that you can not change access. You can only read data because you are creating view on two tables.

16-10.png

Step 15: Save and Activate View.

17-9.png

Step 16: Click on Contents. Here you can see that data from two tables.

18-7.png

Here we have created database view.

In this way you can add more than two tables and create database view.

In this blog post we learn how to create database view on two transparent tables.

Follow my profile to be notified of the next blog post. Please feel free to ask any questions you have in the comments section below.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK