Skip to Content
author's profile photo Former Member
Former Member

About Views

Hi,

Can you plz explain me about

what is the different types of views? When we are using views.? Give me an example for each views.

Shyja

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 06:11 AM

    Hi

    Importance/Use of views

    Join/Projection/Selection w.r.t views

    Inner and Outer joins

    Types of views

    Database view

    Projection view

    Maintenance view

    Help view

    <b>Importance/Use of Views</b>

    Data for an application object is often distributed on several database tables. Database systems therefore provide you with a way of defining application-specific views on the data contained in several tables. These are called views.

    Data from several tables can be combined in a meaningful way using a view (join). You can also hide information that is of no interest to you (projection) or only display those data records that satisfy certain conditions (selection).

    A view is a logical view on one or more tables, that is, a view is not actually physically stored, instead being derived from one or more other tables.

    The data of a view can be displayed exactly like the data of a table in the extended table maintenance.

    <b>Join, Projection and Selection </b>

    CROSS PRODUCT

    Given two tables TABA and TABB. Table TABA has 2 entries and table TABB has 4 entries

    Each record of TABA is first combined with each record of TABB. If a join condition is not defined, the cross product of tables TABA and TABB is displayed with the view.

    <b>Join condition</b>A join condition describes how the records of the two tables are connected.

    <b>Inner Join and Outer Join </b>

    The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join.

    With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view.

    With an outer join, records are also selected for which there is no entry in some of the tables used in the view. (ABAP allows left outer join.)

    The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join.

    <b>Join, Projection and Selection </b>

    <b>Projection</b>

    Sometimes some of the fields of the tables involved in a view are not of interest. The set of fields used in the view can be defined explicitly (projection). In our example, Field 4 is of no interest and can be hidden.

    We specify the fields which we need to show in our view by including them under the view flds tab when creating a view in the dictionary.

    <b>Selection Conditions</b>Selection conditions that are used as a filter can be defined for a view.

    Specifying these conditions under the Selection conditions tab when creating a view in the dictionary would have an effect which is similar to specifying a where clause when writing a select query to restrict data.

    <b>View Types</b>

    Four different view types are supported. These differ in the way in which the view is implemented and in the methods permitted for accessing the view data .

    Database views are implemented with an equivalent view on the database.

    Projection views are used to hide fields of a table (only projection).

    Help views can be used as selection method in Search help.

    Maintenance views permit you to maintain the data distributed on several tables for one application object at one time.

    <b>Database Views </b>

    Database views should be created if want to select logically connected data from different tables simultaneously.

    Database views implement an inner join.

    Application programs can access the data of a database view using the database interface. (Just as we write select queries on database tables, we can write them for views as well.)

    <b>Includes in Database Views </b>

    An entire table can be included in a database view. In this case all the fields of the included table will become fields of the view (whereby you can explicitly exclude certain fields).

    To include one of the tables in the view, enter character * in field View field, the name of the table to be included in field Table and character * again in field Field name on the View fields tab page of the maintenance screen of the view.

    You can also exclude individual fields of an included table. If you do not want to include a field of the included table in the view, enter - in field View field, the name of the included table in field Table and the name of the field to be excluded in field Field name.

    <b>Inserts with Database Views </b>

    If a database view contains only one single table, data can be inserted in this table with the view .

    You have the following options for the contents of the table fields not contained in the view:

    If the field is defined on the database with NOT NULL as initial value, the field is filled with the corresponding initial value.

    If the field is defined on the database as NOT NULL without initial value, an insert is not possible. This results in a database error.

    If the field is not defined on the database as NOT NULL, there will be a NULL value in this field.

    <b>Projection Views </b>

    Projection views are used to hide fields of a table. This can minimize interfaces; for example when you access the database, you only read and write the field contents actually needed

    For the above diagram, fields F3 and F4 are irrelevant, and therefore hidden from the projection view of the table.

    <b>Maintenance Views </b>

    A maintenance view permits you to maintain the data of an application object together.

    The maintenance status determines which accesses to the data of the underlying tables are possible with the maintenance view.

    <b>Maintenance Status </b>

    The maintenance status of a view controls whether data records can also be changed or inserted in the tables contained in the view.

    The maintenance status can be defined as follows:

    Read only: Data can only be read through the view.

    Read, change, delete, insert: Data of the tables contained in the view can be

    changed, deleted, and inserted through the view.

    Read and change: Existing view entries can be changed. However, records

    cannot be deleted or inserted.

    Read and change (time-dependent views): Only entries whose non-time

    dependent part of the key is the same as that of existing entries may be

    inserted.

    <b>Help Views </b>

    Help view is created if a view with outer join is needed as selection method of a search help.

    Help views are used exclusively for search helps.

    A conventional database view selects data from the database using an inner join.

    For a help view however, data is selected using a left outer join.

    Eg-> Suppose table SCARR (Airline master table) has AA – American airlines

    AB – Air Berlin

    AC- Air Canada as three entries.

    Table SPFLI (Flight schedule) has entries corresponding only to airlines AA (American airlines) and AB (Air Berlin).

    Now if a database view were to be used as a selection method for a search help for airlines, we would only get AA and AB as possible entries because the database view implements an inner join…….If however, we were to use a help view as the selection method here, we would get AA,AB and AC as possible entries because a help view would implement a left outer join.

    <b>Restrictions for Maintenance and Help Views </b>

    There are some restrictions for selecting the secondary tables of a maintenance view or help view. The secondary tables have to be in an N:1 dependency to the primary table or directly preceding secondary table. This ensures that there is at most one dependent record in each of the secondary tables for a data record in the primary table.

    <b>Append Views </b>

    Append views are used for enhancements of database views of the SAP standard.

    With an append view, fields of the base tables of the view can be included in the view without modifications. This is analogous to enhancing a table with an append structure.

    An append view is assigned to exactly one database view. More than one append view can be created for a database view.

    The append technique described can only be used for database views. With an append view, only new fields from the base tables contained in the view can be inserted in the view. You cannot insert new tables in the view or modify the join conditions or selection conditions of the view.

    <b>Reward if usefull</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 05:58 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 06:42 AM

    Hi Shyja,

    Different Types of Views

    1.

    Database View

    Creating a Database View Locate the document in its SAP Library structure

    Procedure

    1. Enter an explanatory short text in the field Short text.

    You can for example find the view at a later time using this short text.

    2. Define the tables to be included in the view in the Tables field of the Tables/Join conditions tab page.

    Keep in mind that you can only include transparent tables in a database view.

    3. Link the tables with

    join conditions.

    If there are suitable foreign keys between the tables, you should copy the join conditions from these foreign keys (see Structure link Foreign Key Relationships and Join Conditions).

    Place the cursor on a table name and choose Relationships. All foreign keys to other tables defined for this table are displayed. Select the foreign keys and choose This graphic is explained in the accompanying textCopy. The join condition is now derived from the definitions in the foreign key.

    If you only want to see the foreign key relationship existing between two tables, you must first select these two tables (click on the first column of the input area Tables) and then choose Relationships.

    4. On the View fields tab page, select the fields that you want to copy to the view.

    Choose Table fields. All the tables contained in the view are displayed in a dialog box. Select a table. All the fields contained in this table are displayed. You can copy fields by selecting them in the first column and choosing This graphic is explained in the accompanying textCopy.

    You can also include an entire table in the view (see Includes in Database Views).

    5. On the Selection conditions tab page, you can (optionally) formulate restrictions for the data records to be displayed with the view (see

    Maintaining Selection Conditions for Views).

    The selection conditions define the data records that can be selected with the view.

    6. With Goto ® Technical settings, you can (optionally) maintain the technical settings of the database view.

    You can define whether and how the database view should be buffered here. Proceed as for the technical settings of a table (see Structure link Maintaining Technical Settings). Note that only the settings for buffering can be maintained for database views.

    7. On the Maintenance status tab page, select the

    maintenance status of the database view.

    If the view contains more than one table, the maintenance status read only cannot be altered.

    8. Save your entries. You are asked to assign the view a development class.

    You can change this development class later with Goto ® Object directory entry.

    9. Choose This graphic is explained in the accompanying text.

    Result

    When a database view is activated, the corresponding view is also automatically created in the database if the base tables of the view were already created there.

    At activation, a log is written; it can be displayed with Utilities ® Activation log. If errors or warnings occurring when the view was activated, they are displayed directly in the activation log.

    If the base tables are not yet created in the database, this is recorded in the activation log. The view is nevertheless activated in the ABAP Dictionary. In this case you can create the relevant view on the database later with the database utility.

    Other Options

    • Create documentation: You can create information about using the view with Goto

    • ® Documentation. This documentation is also output for example when you print the view. Change data element of a view field: Select the Mod (Modify) column in the View fields tab page. The Data element field is now ready for input. You can enter a data element that refers to the same domain as the data element of the assigned table field here. Cancel the Mod flag if you want to use the data element of the assigned table field again.

    • Display view data: With Utilities

    • ® Contents you can determine which data can be selected with the view. Display create statement: With Extras

    • ® CREATE statement you can display how the view was created in the database. The statement that was executed when the version of the view currently being edited was created in the database is displayed. Check the definition of the view in the database: With Utilities

    • ® Database object ® Check you can determine whether the definition of the view in the database is consistent with the active version of the view. With Utilities ® Database object ® Display you can display the definition of the view in the database. Check the runtime object of the view: With Utilities

    ® Runtime object ® Check you can determine whether the definition of the view in the ABAP Dictionary maintenance screen is identical to the specifications in the runtime object of the view. With Utilities ® Runtime object ® Display you can display the runtime object of the view.

    2.

    Projection View

    Creating Projection Views Locate the document in its SAP Library structure

    Procedure

    1. Enter an explanatory short text in the field Short text.

    You can for example find the view at a later time using this short text.

    2. Enter a table name in the field Base table.

    A projection view always contains exactly one table.

    3. Select the fields of the base table that you want to include in the view.

    Choose Table fields. The fields of the table are now displayed in a dialog box. You can copy fields by selecting them in the first column and choosing This graphic is explained in the accompanying textCopy.

    4. Save your entries.

    You are asked to assign the view a development class. You can change this development class later with Goto ® Object directory entry.

    5. Choose This graphic is explained in the accompanying text.

    Result

    The help view is activated. At activation, a log is written; it can be displayed with Utilities ® Activation log. If errors or warnings occurring when the view was activated, they are displayed directly in the activation log.

    Other Options

    • Create documentation: You can create information about using the view with Goto

    • ® Documentation. This documentation is output for example when you print the view. Change data element of a view field: Select column Mod (modification) for the particular view field. The Data element field is now ready for input. You can enter a data element that refers to the same domain as the data element of the assigned table field here. Cancel the Mod flag if you want to use the data element of the assigned table field again.

    • Change maintenance status: The

    • maintenance status determines how you can access the view data from ABAP programs (read only, read and change). Choose Extras ® Maintenance status. A dialog box appears in which you can select the maintenance status of the view. Check functions: With Utilities

    ® Runtime object ® Check you can determine whether the definition of the view in the ABAP Dictionary maintenance screen is identical to the specifications in the runtime object of the view. With Utilities ® Runtime object ® Display you can display the runtime object of the view.

    3.

    Maintainence View

    Maintenance View Locate the document in its SAP Library structure

    Definition

    Related data in several tables can be maintained together in a maintenance view.

    Structure

    A maintenance view has the samee key as its primary table. To ensure that the system can write the records inserted in a maintenance view correctly into the tables in the view, put all key fields of the primary table in a maintenance view.

    Each entry in the primary table can have at most one dependent data record in the secondry table. The only exceptions are the text tables of tables in the view which have the additional key field Language. The system puts the logon language in the language field during the table maintenance. You cannot put the language field in the view explicitly.

    You can maintain text table entries in other languages with the translation function in transaction SM30.

    Caution

    You must regenerate the maintenance dialog if you change the definition of a table/view with a generated maintenance dialog, e.g. add or remove fields, or change the maintenance attribute or a selection condition.

    Maintenance Attributes

    You can assign a maintenance attribute P to individual fields in the maintenance view definition in the Dictionary (SE11). It can be R (read only), H (hidden), or S (subset).

    • R (readonly)

    A field flagged R is not ready for input by the user on the screen. When a new data record is created, it must be filled automatically in the background. To fill a field automatically in the background, create a routine for an event.

    • H (hidden)

    A field flagged H is not displayed on the screen. This field must also be filled in the background by a routine at an event.

    The system writes R and H fields to the database like all other fields when a new data record is saved.

    • S (subset)

    A field flagged S restricts the work area.

    The system only shows data records for which this subset field has the specified value. This restriction of the work area remains effective when you create new data records.

    View Variant

    You can define any number of view variants for an existing view. The view variants do not have their own generated maintenance dialogs, they use the base view. The view variants can differ from their base view by different selection conditions and a different field selection.

    4.

    Help View

    Creating Help Views Locate the document in its SAP Library structure

    Procedure

    1. Enter an explanatory short text in the field Short text.

    You can for example find the view at a later time using this short text.

    2. Enter the primary table of the view under Tables in the Tables/Join conditions tab page.

    Only tables that are linked with the primary table (indirectly) with a foreign key can be included in the view.

    3. Save your entries.

    You are asked to assign the help view a development class. You can change this development class later with Extras ® Object directory entry.

    4. If required, include more tables in the view. In a help view you can only include tables that are linked to one another with foreign keys.

    Position the cursor on the primary table and choose Relationships. All existing foreign key relationships of the primary table are displayed. Select the foreign keys and choose This graphic is explained in the accompanying textCopy. The secondary table involved in such a foreign key is included in the view. The join conditions derived from the foreign keys (see Structure link Foreign Key Relationship and Join Condition) are displayed.

    You can also include tables that are linked with a foreign key to one of the secondary tables already included. To do this, place the cursor on the secondary table and choose Relationships. Then proceed as described above.

    For maintenance and help views, there are certain restrictions on the foreign keys with which the tables can be included in the view (see Restrictions for Maintenance and Help Views). The foreign keys violating these conditions are displayed at the end of the list under the header Relationships with unsuitable cardinality.

    5. On the View fields tab page, select the fields that you want to copy to the view. The key fields of the primary table were automatically copied to the view as proposals.

    Choose Table fields. All the tables contained in the view are listed in a dialog box. Select a table. The fields of the table are now displayed in a dialog box. Select the required fields in the first column and choose This graphic is explained in the accompanying textCopy.

    6. On the Selection conditions tab page, you can (optionally) formulate restrictions for the data records to be displayed with the view (see

    Maintaining Selection Conditions for Views).

    The selection conditions define the data records that can be selected with the view.

    7. Choose This graphic is explained in the accompanying text.

    Result

    The view is now activated. At activation, a log is written; it can be displayed with Utilities ® Activation log. If errors or warnings occurring when the view was activated, they are displayed directly in the activation log.

    Other Options

    • Create documentation: You can create information about using the view with Goto

    • ® Documentation. This documentation is output for example when you print the view. Change data element of a view field: Select column Mod (modification) for the view field. The Data element field is now ready for input. Enter the new data element there. You can enter a data element that refers to the same domain as the data element of the assigned table field here. Cancel the Mod flag if you want to use the data element of the assigned table field again.

    • Check functions: With Extras

    ® Runtime object ® Check you can determine whether the definition of the view in the ABAP Dictionary maintenance screen is identical to the definitions in the runtime object of the view. With Extras ® Runtime object ® Display you can display the runtime object of the view.

    Regards,

    Chandru

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.