This is the next blog post in this series. Here is the previous blog post
Getting Started with ABAP: How to Create Database 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.
Step 2: Click on Create. Select Database View.
Step 3: Enter short description.
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
ZAK_DEP
First, I entered one table.
Step 5: Click on Relationships.
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.
Step 7: Select View Fields tab.
Step 8: Click on Table Fields.
Step 9: Select first table name. Then you will get below window.
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.
Step 11: You will get below window. Click on Table Fields.
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.
Step 13: Click on Copy.
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.
Step 15: Save and Activate View.
Step 16: Click on Contents. Here you can see that data from two tables.
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.
Here you can check next blog post
Getting Started with ABAP: How to Create Projection View
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.