SAP CDS DEFINE VIEW AS ANALYTICAL



Get Example source ABAP code based on a different SAP table
  


• DEFINE TRANSIENT VIEW ENTITY ABAP_CDS_ANALYTICAL
• AS ABAP_CDS_ANALYTICAL
• AS PROJECTION ON ABAP_CDS_ANALYTICAL

ABAP_CDS_DDL - DEFINE TRANSIENT VIEW ENTITY AS PROJECTION ON,Analytical Query

ABAP_SYNTAX
$[@entity_annot1$]
$[@entity_annot2$]
...
@AccessControl.authorizationCheck: #NOT_ALLOWED
$[@proj_view_annot1$]
...
DEFINE TRANSIENT VIEW ENTITY analytical_query
PROVIDER CONTRACT ANALYTICAL_QUERY
$[parameter_list$]
AS PROJECTION ON cds_entity $[AS alias_name$]
{ element_list }
$[WHERE cds_cond$]

What does it do?
Defines a CDS analytical projection view with the name analytical_query in CDS DDL . A CDS analytical projection view defines an analytical query in its element_list.
The projected entity cds_entity can be an analytical cube view or an analytical dimension view. One base view can serve as a basis for multiple analytical projection views.
The name of the CDS analytical projection view analytical_query is defined after the DEFINE TRANSIENT VIEW ENTITY statement. It must comply with the naming rules for ABAP CDS with one specialization: It can have a maximum of 28 characters (instead of 30 characters), because the analytical engine automatically adds the prefix 2C during further processing.

ABAP_PREREQUISITES
The header annotation @AccessControl.authorizationCheck must be specified with the value #NOT_ALLOWED. Analytical queries cannot be accessed using AB_SQL and therefore, no CDS access control can be specified. Instead, the CDS access control of the projected entity is applied.
The projected entity must be one of the following:
An analytical cube view, annotated with the framework-specific annotation @Analytics.dataCategory: #CUBE.
An analytical dimension view annotated with the framework-specific annotation @Analytics.dataCategory: #DIMENSION.
ABAP_PREREQ_END

Components
Header annotations specified before the statement DEFINE TRANSIENT 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 mandatory keyword TRANSIENT defines a CDS analytical projection view as transient CDS view entity. That means that only a runtime object on the ABAP server is generated, but no SQL view is generated on the HANA database.
The provider contract must be specified with the value ANALYTICAL_QUERY to ensure that the appropriate features and syntax checks for analytical queries are applied.
parameter_list can be used to assign input parameters to the projection view. These input parameters can be specified in operand positions of the view and can be assigned actual parameters when the view is used.
The optional addition AS 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.
The element list element_list defines the components of the analytical query.
Optionally, the number of rows included in the result set can be further restricted by the addition WHERE.

ABAP_RESTRICTION
Defining new associations in the projection layer is not possible.
Exposing associations is not allowed either.
ABAP_RESTR_END

ABAP_EXAMPLE_VX5
The following CDS analytical projection view DEMO_ANALYTICAL_QUERY defines an analytical query. It is based on the cube view DEMO_CDS_CUBE_VIEW.
DDLS DEMO_ANALYTICAL_QUERY
ABAP_EXAMPLE_END