Ansicht
Dokumentation

ABENDDIC_DATABASE_VIEWS - DDIC DATABASE VIEWS

ABENDDIC_DATABASE_VIEWS - DDIC DATABASE VIEWS

Vendor Master (General Section)   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.
SAP E-Book

- Database Views

A DDIC database view is a general view for one or more basis tables. If there are multiple basis tables, they are joined using an inner join. A corresponding SQL view is created as a database object on the database when the view is activated. The structure type defined using the view fields of the database view can be referenced in ABAP programs using TYPE. A database view can be accessed using , AMDP, Native SQL, in CDS views, and also from outside AS ABAP using the programming interface of the database. The latter method is, however, not recommended.

Notes

  • A DDIC database view can be activated in ABAP Dictionary without its basis tables being defined on the database. The view is also not created on the database in this case.
  • As in a DDIC database table, the client dependency of a database view is determined by an initial column with the built-in dictionary type CLNT.
  • DDIC append views are available for enhancing the database views in ABAP Dictionary delivered by SAP without making any modifications.
  • Suitable CDS views can be defined as replacement objects for database views. In this case, reads in access the replacement objects rather than the database views.

Basis Tables

The basis tables of database views can be transparent tables and global temporary tables.

Note

The basis tables of CDS-managed DDIC views that are generated for CDS views can also be other DDIC database views.

View Fields

An include mechanism can be used to add individual fields or all fields from the basis tables as view fields of a DDIC database view. When individual fields are used, a name other than the name in the basis tables, can be defined for a view field. This name can have a maximum of 30 characters, must meet the naming conventions for component names of DDIC structures, and cannot be a reserved name. The reserved names that cannot be used are specified in the database table TRESE. Fields with the type CHAR can have a maximum of 1333 characters. Fields with the type LRAW or LCHR must be at the end of the view. Only one such field is allowed per view. Furthermore, a field with the type INT2 or INT4 (for the maximum length of the field) must be located directly in front of this field.

To use all fields, the * character is used instead of the field name. If the - character is used for individual fields of a basis table included using *, all fields up to the fields specified with - become view fields. If the structure of a DDIC database table whose fields were added in this way is modified, the structure of the view is also modified.

Notes

  • If a foreign key field is added as a view field, it keeps this attribute and all associated foreign key fields become the foreign key of the view.
  • A DDIC database view in the software component SAP_BASIS can contain a maximum of 749 view fields and the total of the field lengths (the number of bytes in non-character-like fields plus the number of characters in flat character-like fields) must not exceed 4096. A database view in any other software component can contain a maximum of 1500 view fields and the total of the field lengths is not checked in ABAP Dictionary.

Join Conditions

The join conditions for the inner join can be formulated using equality relationships between any two table fields in the basis tables. The inner join joins the rows of the basis tables in question as a result set containing all combinations of rows whose columns together meet the join conditions. If there are no rows that meet the join conditions in the basis tables in question, no row is created in the result set. If there is a suitable foreign key dependency (including generic and constant foreign keys) between two basis tables, this dependency can be used as a default for defining join conditions in ABAP Dictionary.

Maintenance Status

The Access setting in the maintenance status of a DDIC database view can have the following values:

  • Read only
The database view can only be used to read data with .
  • Read, change, delete, and insert
If the database view contains only a single basis table, data can be changed using .

A database view with multiple basis tables can only be read with . If a database view contains only a single table, data can be inserted in this table using the view with the statements INSERT or MODIFY. The following options are available for the content of the table fields not in the view:

  • If the table field is defined with NOT NULL on the database, the field is filled with the corresponding initial value.
  • If the table field is defined with NOT NULL on the database, and there is no initial value, nothing can be inserted and a database error occurs with a corresponding exception.
  • If the table field is not defined with NOT NULL on the database, the field is filled with the null value.

Notes

  • A DDIC database view should only be used to insert data in the table if the flag for initial values is set for all table fields that are not in the view.
  • It is not usually a problem to modify existing data records using a database view in cases where the database view contains all key fields of the table.
  • Like a DDIC database table, the maintenance status of a database view has a Display and Maintain setting alongside the Access setting. The setting must match the Access setting. In database views containing multiple basis tables, only the setting Display/maintenance not allowed is possible.

Table Buffering

Just like in DDIC database tables, it is possible to define for a database view whether the data in the table buffer is buffered. The same buffering types can be defined and table buffering in is handled in the same way for views and for DDIC database tables with the only difference being that, when data is modified in one of the basis tables, the entire buffer is invalidated when the buffers are synchronized, regardless of the buffering type In client-dependent views, however, this only affects the content of the current client. As for DDIC database tables, the settings for buffering are separate technical settings, that can be transported independently from the view.

The following prerequisites must be met before a DDIC database view can be buffered:

  • A basis table can occur in no more than nine buffered database views.
  • If all fields of the database view are key fields, these fields must also be key fields of the basis tables.

Note

No replacement objects can be created for an existing buffered view whose data can be written to using .

Example

The DDIC database view DEMO_SCARR_SPFLI contains fields of the tables SCARR and SPFLI. Other names are assigned to these fields in the view.

The associated database object could be as follows:

CREATE VIEW DEMO_SCARR_SPFLI
   (CLIENT,
   ID,
   CARRIER,
   FLIGHT,
   DEPARTURE,
   DESTINATION )
AS SELECT
   T1."MANDT",
   T2."CARRID",
   T1."CARRNAME",
   T2."CONNID",
   T2."CITYFROM",
   T2."CITYTO"
FROM
    "SCARR" T1,
    "SPFLI" T2
WHERE
    T1."MANDT"  = T2."MANDT" AND
    T1."CARRID" = T2."CARRID"

The view can be accessed as follows using :






Vendor Master (General Section)   CPI1466 during Backup  
This documentation is copyright by SAP AG.

Length: 12544 Date: 20240420 Time: 093019     sap01-206 ( 171 ms )