Creating Database Views 

Procedure

  1. Select the object class View in the initial screen of the ABAP Dictionary, enter the view name and choose Create.
  2. A dialog box appears in which you must select the view type.

  3. Select the type Database view and choose Choose.
  4. The maintenance screen for database views appears. You will see three input areas for tables, join conditions and view fields.

  5. Enter an explanatory short text in the field Short text.
  6. Under Tables, enter the base tables that you want to include in the view.
  7. Link the tables with join conditions. Enter the fields that you want to identify under Join conditions.
  8. You can also derive the join conditions from foreign keys that are already defined between the base tables of the view. To do this, position the cursor on the table names and choose Relationships. All foreign keys to other tables defined for this table are displayed.

    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.

    Select the foreign key and choose Copy. The join condition is now derived from the definitions in the foreign key (see Foreign Key Relationship and Join Condition).

  9. Select the fields that you want to include in the view.
  10. To do this, position the cursor on a table and choose TabFields. The fields of the table are now displayed in a dialog box. You can copy fields from here by marking them in the first column and choosing Copy.

    You can also completely include a table in the view. The view then adapts itself automatically to changes in this table. If fields are inserted or deleted in the included table, these fields are also inserted or deleted in the view.

    In order to include one of the tables in the view, you must enter * in the field View field *, the name of the table to be included in the field Table and * in the field Field name.

    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, you must specify a - in the field View field, the name of the included table in the field Table and the name of the field in the field Field name.

  11. Formulate the selection conditions. To do this choose Goto ® Selection condition.
  12. The input area for the selection conditions appears in place of the input area for the fields. Maintain the selection condition as described in Maintaining Selection Conditions of Views. You can then switch back to the fields display with Goto ® View fields.

  13. Maintain the technical settings of the view.
  14. You can define whether and how the view should be buffered here. When maintaining, proceed as for the technical settings of a table (see Maintaining Technical Settings). Note that only the settings for buffering can be maintained for views.

  15. Save your entries.
  16. You are asked to assign the view a development class. You can change this development class later with Extras ® Object directory entry.

  17. Activate the view with View ® Activate.

A log is written during activation. You can display it with Utilities ® Activation log. If errors or warnings occurring during activation of the view, they are displayed directly in the activation log.

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.

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 database view later with the database utility.

Other Options

Creating Documentation

You can create information about using the view with Goto ® Documentation. This documentation is output for example when you print the view.

Changing the Data Element of a View

Select the Mod column (modify) for the view field and choose Enter. The Data element field is now ready for input. Enter the new data element there. This data element must refer to the same domain as the original data element. With the input help (F4 help) for the Data element field, you can display all the data elements that refer to the domain of the field.

If you want to assign the original data element again, you only have to reset the Mod flag and choose Enter.

Changing the 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. If more than one table is included in the view, the maintenance status read only cannot be altered.

Displaying View Data

With Utilities ® Display data you can determine which data can be selected with the view.

Displaying Create Statement

With Extras ® CREATE instruction 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 Functions

With Extras ® 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 Extras ® Database object ® Display you can display the definition of the view in the database.

With Extras ® 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 Extras ® Runtime object ® Display you can display the runtime object of the view.

Displaying Foreign Keys of View Fields

If a foreign key that was automatically copied to the view definition during activation is defined for the field of the base table, you can display it. To do so, position the cursor on the view field and choose Extras ® Foreign keys.

See also:

Database Views