SAP NetWeaver AS ABAP Release 750, ©Copyright 2016 SAP AG. All rights reserved.
ABAP - Keyword Documentation →
ABAP - Dictionary →
Classic Objects in ABAP Dictionary →
Replacement Objects
A CDS view can be assigned (using the name of its
CDS entity) as a replacement object to a
transparent
database table and to a classic
database view in ABAP Dictionary. The prerequisite
here is that the structure type that is defined by the database table or by the classic view is the same as the structure type defined by the CDS view.
- The number of components must match.
- The names of the components must match (except for the client column) and must be in the same order.
- The technical type properties predefined data type, length and number of decimal places must match for every component.
- The CDS view cannot have any input parameters.
- It is not possible to simultaneously have a replacement object defined and SAP buffering switched on for a database view with a changeable maintenance status.
In the following cases if a database table or a classic view is accessed and a replacement object is assigned to the table or view, the replacement object is evaluated instead of the database table or classic view:
All other access types are still performed on the database table or classic view such as:
-
Writes like this produce a syntax check warning and are forbidden in strict mode from Release 7.50.
- Use in other database objects, such as:
- Use as a data source of a view defined on the database
- Access from database procedures or database functions
-
Here it is not important how the database object was created. This means, in addition to natively created views, the views defined for
classic
database views in ABAP Dictionary or for
CDS views on the database also do not access the replacement object. A similar principle applies to
AMDP procedures and
AMDP functions. Even if Open SQL is used to access a classic database view of ABAP Dictionary, a CDS view or a
CDS table function,
which comprises database tables with replacement objects, no redirection occurs. In these cases, the
replacement object must be accessed directly. For classic database views, a replacement object can be created that performs this task without the need to modify the programs.
- Other access types than with Open SQL, for example:
When you define a replacement object for a database table for a classic database view, the system checks
whether the specified CDS view fulfills the prerequisites. If a CDS view used as a replacement object
is changed later on in such a way that the prerequisites are no longer fulfilled, a runtime error
DBSQL_REDIRECT_INCONSISTENCY occurs when an Open SQL read is performed on the database table or on the database view.
No replacement objects can be defined for
global temporary tables. In customer systems, replacement objects can only be defined for self-defined database views but not for database tables.
Notes
- You should be extremely careful when specifying a proxy object for a database table or a database view. Incorrect usage can cause inconsistencies.
- Replacement objects are mainly intended for existing aggregate tables. These are database tables,
which contain aggregated data from other tables. Instead of aggregating data in an ABAP program and
writing data to an aggregate table, which can be exclusively accessed by reads in programs, the aggregation
can be performed for every read using the CDS view. This prevents redundant data from being stored.
In addition, aggregation on the database can improve performance if it is necessary to read large volumes
of data for aggregation in ABAP. Replacement objects can make this possible without invalidating the programs.
- The prerequisite for assigning a replacement object to an existing database table or database view
is that the CDS view returns the expected data and that, apart from aggregation, only Open SQL reads are performed on the aggregate table.
- After the definition of a replacement object, no further writes should be performed on an aggregate table. These writes result in a warning from the syntax check and have been banned in the upcoming release.
- Make sure that apart from the use of Open SQL, no other type of access is performed on an aggregate
table with a replacement object. The CDS view used as a replacement object in particular is not allowed to access the represented object, because the content is usually no longer updated.
- We do not recommend transporting table content for which a replacement object is defined. These contents are automatically no longer transported in the upcoming release.
- SAP buffering should be deactivated for an aggregate table for which a replacement object is defined, in order to prevent buffer invalidations.
- In customer systems, it may be useful to define a replacement object for a self-defined classic
database view, if a replacement object has been defined for one of their basis tables at SAP. In this case, the replacement object of the view must access the replacement object of the basis table.
- The classic projection view,
maintenance views and
help views are not defined
on the database. Access to their basis tables is carried out on AS ABAP by using Open SQL. If a basis table has a replacement object, its reads are redirected as required.
- Frameworks that use Open SQL, such as the
Data Browser, automatically access replacement objects, if these objects are defined for a database table or a database view. Frameworks that use Native SQL, such as
SADL, have to make sure that they access a replacement object rather than the database table or the database view.
- Wherever possible, any programs, which have been directly accessing aggregate tables or views with
aggregate tables as basis tables, should be modified so that they directly access the CDS views that
are used as replacement objects. However, this can usually not be done by simply replacing the data source in the relevant SELECT statements. This is because a
client-specific CDS view does not have a client column and therefore the used target objects no longer match.
- Replacement objects cannot be defined for
Example
See Replacement Object for Database Table.
Continue
Replacement Object for Database Table