Online Tutorials & Training Materials | STechies.com
Register Login

View and Types of View

|| || 0

View and Types of View
Stechies

View in ABAP

A view is a 'virtual table' containing fields from one or more tables.

A view is a logical view on one or more tables. A view on one or more tables i.e, the data from a view is not actually physically stored instead being derived from one or more tables. A view can be used to summarize data which is distributed among several tables

A view is a virtual table. Every view has a Query attached to it. (The Query is a SELECT statement that identifies the columns and rows of the table(s) the view uses.)

A view is based on a table or another view and acts as a window through which data on tables can be viewed or changed. A view does not contain data. The definition of the view is stored in the data dictionary. You can see definition of view in user_view data dictionary table.
more view options are... these..

  • Can be simple view, based on one table
  • Can be a complex view based on more than one table or can contain groups of functi.ons
  • Can replace other view with same name
  • Can contain a check constraint
  • Can be read-only

In layman's term, View is ABAP is similar to a database table but without the requirement of storage space. It is almost like a virtual table that has no physical existence. In a view, information from one or more tables with application object are combined. Therefore, it becomes helpful in representing a subset of data included in a table. It can also be used to combine various tables into one virtual table.

How to Create a view in ABAP?

The steps to create a view in ABAP are-

  • In the initial ABAP Dictionary screen, click on the View radio button. Input the name of the view and click on Create.
  • Choose the view type and click on Copy.
  • Enter a  description in the Short Description field of the ‘Dictionary: Change View’ screen.
  • Select the ‘Table fields’ button to insert the fields in the table of the projection view.
  • In the Field Selection from Table screen, choose the fields to include in projection view.
  • To display the selected fields on the ‘Dictionary: Change View’ screen click on Copy.
  • Define access method on the Maintenance Status tab.
  • Save and activate the changes.
  • Click on Utilities and then in Contents.
  • Click on Execute.

What is Selection Views?

Selection Views are a collection of fields from different database tables. You can create them in the Repository Browser or the Logical Database Builder in the ABAP Workbench. A virtual table that does not contain any data, but instead provides an application-oriented view of one or more ABAP Dictionary tables.

You can define joins between database tables statically and system wide as views in the ABAP Dictionary. ABAP Dictionary views can be used by all ABAP programs. One of their advantages is that fields that are common to both tables (join fields) are only transferred once from the database to the application server.

Views in the ABAP Dictionary are implemented as inner joins. If the inner table contains no lines that correspond to lines in the outer table, no data is transferred. This is not always the desired result. For example, when you read data from a text table, you want to include lines in the selection even if the corresponding text does not exist in the required language. If you want to include all of the data from the outer table, you can program a left outer join in ABAP.

Different Type of View in ABAP

  • Projection View - Just retrieves some fields from a single table.
  • Help View - This is used for search help.
  • Database View - This is inner join view of one or more tables.
  • Maintenance View - Helps in creating maintaining data of the application object. The data can be distributed among several tables.

1) Projection View

A projection view is used to hide certain fields from in a given table. The main purpose of Projection views is gaining access to pooled, cluster as well as transparent tables. There are no selection conditions in a projection view. The definition of the structure type lies in the view fields that may be referenced to using TYPE in ABAP. The access to projection view is through an Open SQL, not Native SQL. The Open SQL statement to accesses a projection view is manipulated to the platform-specific SQL statement within the database for results. The values of the Access setting may be read-only or read, change, delete, and insert.

2) Help View

A help view is used to search helps. The search help can select database tables, database views, and special help views. However, in the case of database tables, the search help is restricted to one table and in database views, it is restricted to the inner joins. A help view cannot be defined in the database. The referencing to the structure type is defined using a help view with TYPE. One cannot access help view with an Open SQL.

The join conditions are applied in a help view with the help of existing foreign keys. This means only the tables joined with foreign keys can be grouped using help view. The first table in the help view is known as the primary table while the others are known as secondary tables.

3) Database View

A database view is a general view used for one or more basis tables. Multiple basis tables are joined with an inner join with the creation of a matching SQL view once the view is activated. It is possible to access a database view using both Open SQL and Native SQL. The main components of a database view are-

  • Basis Tables
  • View Fields
  • Join Conditions
  • Maintenance Status
  • SAP Buffering

4) Maintenance View

A maintenance view performs writes on various tables with the help of extended table maintenance. One maintenance view may change the contents of several related database tables unfailingly. It is not explained on the database but the structure type is defined using TYPE on ABAP. One cannot access maintenance using Open SQL. The SE54 transactions are used in the creation of maintenance dialogues for maintenance views to edit all  the maintenance views tables together. The main components of this view include-

  • Primary Table and Secondary Tables
  • Time-Dependent Key
  • Maintenance Status
  • Maintenance Characteristics of View Fields
  • Delivery Class

Thus, every view has its own purpose. Data belonging to an application object spread across many tables are combined using database views. A maintenance view displays and modifies data within an application object. Projection view masks unnecessary fields and helps view helps to search helps. One can use the views to suit their needs and get desirable results.


Related Articles