Database Views in ABAP
Note: The join conditions used in this view can be applied using the equality relationship between any base fields. But in other views type(maintenance, help, and projection view), the join condition must be achieved using the foreign key relationship.The below diagram explains the working of the ABAP database view: Key features of database view
Creating Database viewBelow are the steps used to create the database view in SAP ABAP: Step-1: Open the data dictionary initial screen by navigating the menu path or entering the transaction code SE11 in the command field. Step-2: Click the radio button in front of View option, and give a name to the view then click the Create button given on the screen. Step-4: A pop-up window will appear with all the views, from where select the "Database view" and click on the Copy button. Step-5: A view maintains screen appears that contains multiple tabs, where first provide the description in the field "Short description." Consider the below image: In the above screen, first, we will select the Table/Join Conditions tab and will provide the table names (base tables) that we want to link. In our example, we will take two SAP standard tables that are MARA and MARC. After entering the table name, we need to click on the Relationships button. Consider the below image: Step:7- When we click on the Relationships button, all the tables with the foreign key relationship with the base table (MARA) will be displayed. Consider the below image: As another table, we have selected MARC (SAP standard table), and clicked on the Copy button, given at the bottom of the screen. Step-8: Once we will select the MARC table, all the join conditions field names will be filled automatically. Consider the below image: Step-9: Now, we will move to the next tab, which is View fields, to select the fields of both tables that we want to display. Consider the below image: Step-10: To select the fields of each table, we need to click on the Table fields button given on the screen (See the above image). It will open a new pop window with both table names (MARA and MARC). We will select one table at a time and will select the required fields of each table. Step-11: Once we click on the Choose button given at the bottom of the screen, it will open all the fields of the selected table from where we can select the required fields. Consider the below image: After selecting the fields, click on the Copy button. Similarly, we will choose the fields of another table (MARC). Step-12: After selecting all the required fields of both tables, save the view as a local object and activate the view (CTRL+F3) or by clicking on the activate button. Consider the below image: Step-13: The activation window will open, select the View, and click to the Green tick. Step-14: Now, we can display the records that we have selected using the database view. For this, click on the Content (CTRL+SHIFT+F10) option given at the screen. Once we click on the content option, it will open the selection screen as given in the below image: In the above, we can see all the fields of the table are displayed that we have selected from both the table. We can either fill the details in the field for the particular record or can view all the records using the execute button given at the above image. It will display all the records, consider the below image: Next TopicABAP Projection View |