5
Creating Database Views By Pranshu Kukreti, Infosys Introduction Database views are used to combine application data often distributed over several tables. The of such views is defined by specifying the tables and fields that are reuired. !ields which ar can be hidden, thereby minimi"ing the interfaces. # view can be used in #B#P programs for data selection. !ollowing demo shows how to create database view for two database tables having fo relationship. $e will be creating a database view for below shown tables %&'()B#*K + %&'()# - *T/. *ote that %&'()# - *T/ is foreign key table 0dependent table1 and %&'()B#*K is check table 0referenced table1 for field B2#* 3)ID. It should be kept in the mind that we can only include transparent database view. /teps '. 4o to transaction /5'' 67 select radio button 89iew8 67 enter the name of the view 67 press

Creating Database Views

Embed Size (px)

DESCRIPTION

Creating Database Views

Citation preview

Creating Database ViewsBy Pranshu Kukreti, InfosysIntroductionDatabase 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.Steps1.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 pressbutton.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 onpresent 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 pressingbutton 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.