Ansicht
Dokumentation

ABENCDS_DEFINE_VIEW_AS_PROJECTION - CDS DEFINE VIEW AS PROJECTION

ABENCDS_DEFINE_VIEW_AS_PROJECTION - CDS DEFINE VIEW AS PROJECTION

ABAP Short Reference   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

- DEFINE VIEW ENTITY AS PROJECTION ON, Transactional Query

$[@entity_annot1$]
$[@entity_annot2$]
...
$[@proj_view_annot1$]
$[@proj_view_annot2$]
...
DEFINE $[ROOT$] VIEW ENTITY projection_view
   $[PROVIDER CONTRACT TRANSACTIONAL_QUERY$]
    AS PROJECTION ON cds_entity $[AS alias_name$]
   $[ association1 association2 ...$]
   $[redefined_assoc1 redefined_assoc2 ...$]
      { projection_list }
   $[WHERE cds_cond$]


Additions

1. ... ROOT

2. ... AS alias_name

Effect

Defines a CDS transactional query with the name projection_view in CDS DDL. A CDS projection view is a direct projection of an underlying CDS entity cds_entity (called projected entity) and exposes a subset of the elements of the projected entity, which are defined in the projection list projection_list.

The projected entity cds_entity can be either a CDS view entity or a (deprecated). No other CDS entities or data sources are allowed as projected entity. Path expressions are not allowed for specifying the projected entity. One CDS entity can be used as basis for multiple CDS projection views.

The name of the CDS projection view projection_view is defined after the DEFINE VIEW ENTITY statement. The usual rules for ABAP Dictionary views apply to this name and it is not case-sensitive (it is transformed internally into uppercase letters). It can have a maximum of 30 characters and is in the namespace of all global types of an AS ABAP. The name of the DDL source and of the CDS entity must be identical.

A CDS transactional query that uses the addition PROVIDER CONTRACT TRANSACTIONAL_QUERY must be part of a RAP business object. That means that the view must either be a root entity itself, or it must be part of a composition tree and reach a root entity via a composition.

Components

  • Header annotations specified before the statement DEFINE VIEW ENTITY are not inherited from the projected entity. It is possible, but not mandatory, to specify entity annotations @entity_annot or projection view annotations @proj_view_annot as header annotations.
  • The provider contract specifies the scenario in which the projection view is used. It is recommended that a provider contract is always specified. Otherwise, no runtime-specific syntax checks are applied. See the topic about provider contracts for further details.
  • It is possible to add new, local, read-only associations association1, association2 to a projection view after the view definition with DEFINE VIEW ENTITY AS PROJECTION ON. The same rules apply as to associations in CDS view entities. The main difference is that read-only associations in projection views can only be exposed but they can't be used in path expressions to expose elements from new associations. Details on new local associations in CDS projection views can be found in topic CDS DDL - projection_view, ASSOCIATION.
  • Optionally, the number of rows included in the result set can be further restricted by the addition WHERE.

Note

CDS access control defined for a CDS transactional query must be defined symmetrically to the CDS access control for the projected entity. All behavior of the access control of the projected entity must be inherited.

Example

The following CDS transactional query DEMO_SALES_PV_BUPA is a projection of the existing CDS view DEMO_SALES_CDS_BUPA. The result set contains only rows where the last name of the business partner starts with "P".

Example

The following CDS transactional query DEMO_SALES_PV_SO_I_SL is a projection of the existing CDS view DEMO_SALES_CDS_SO_I_SL. It exposes a subset of the elements of the projected entity as well as an association.

A provider contract is not specified, since the provider contract is specified only once in the root entity of a CDS composition tree and all child entities automatically inherit this provider contract. In this case, the root entity is DEMO_SALES_PV_SO and it specifies the business object as transactional query.

Addition 1

... ROOT

Effect

The keyword ROOT specifies that the projection view is the root entity of a composition tree. The projection view must always reflect the position of the projected entity in the composition tree: if the projected entity is a root entity, the projection view must be a root as well. If the projected entity is not a root, the projection view cannot be a root. In this case, the projected entity must contain a to-parent association.

If a CDS projection view is defined as transactional query using the addition PROVIDER CONTRACT TRANSACTIONAL_QUERY, then the view must either be a root entity itself, or it must be part of a composition tree and reach a root entity via an association.

Addition 2

... AS alias_name

Effect

Defines the name alias_name as alias name of the projected entity. The alias name can have a maximum of 30 characters. If no name is defined explicitly using AS, then the original name of the data source is used.






rdisp/max_wprun_time - Maximum work process run time   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.

Length: 11410 Date: 20240419 Time: 231935     sap01-206 ( 118 ms )