Creating Database Views

By Pranshu Kukreti, Infosys

Introduction

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

 

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

   

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

  

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.  

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.

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image