Introduction:
This blog post will explain how to create a CDS view to be used as an ODP-based extractor in BW. Included will be step-by-step details of all necessary objects and code.
Overview:
CDS views have quickly become a core technology for data modeling within the SAP landscape. These views, which are consumed at the database level, allow developers to create structured and performant models that can be directly exposed to reporting tools or used for data extraction.
NIMBL has successfully utilized CDS views as the source for BW extractions across multiple SAP S/4HANA conversion projects. Faced with extractors not replaced by SAP throughout various modules - including, but not limited to: FI, EH&S, PM, and master data - we were able to effectively implement new, high-performing sources, capable of both full and delta extraction.
How-to:
Prerequisites
- First, Eclipse IDE should be installed.
- Next, SAP ABAP tools should be installed using the following steps:
- On the navigation menu, select Help > Install New Software
- Add a new repository to add SAP development tools. This link is for the 2019-12 version of Eclipse, and is provided as an example: https://tools.hana.ondemand.com/2019-12
- For this development, ABAP and BW tools are necessary. Check both options and follow the installation wizard, selecting to allow all installations throughout the process. Eclipse will restart multiple times.
Project Creation
- In the project explorer of the ABAP perspective, right-click and select New > ABAP Project.
- Select the system that you wish to work in and proceed through the wizard to connect.
View Creation
- Under your new ABAP project, either create or navigate to the package you want to work in.
- Expanding the package, right-click and select New > Other ABAP Repository Object.
- In the creation wizard, search for “Data,” and choose “Data Definition” (DDL).
- The DDL name is limited to 30 characters. NIMBL has found success adhering to the following naming convention: ZCDS_BW<module><view type>_<name>_<data type>
- View Types:
- BASIC = I
- COMPOSITE = C
- CONSUMPTION = S
- Data Types:
- Attribute = ATTR
- Text = TEXT
- Hierarchy = HIER
- Transactional = TRAN
- Example: ZCDS_BWFII_WBRP_TRAN
Using a CDS view as the source for a BW extractor requires the use of two view types:
- Basic views, which are created on database tables and fetch results without redundancies. These views are simply raw data from the source tables.
- Composite views, which are created on basic views and are used to join/union multiple basic views and perform calculations.
Basic Views
This example is a basic view that pulls data from SAP table WBRK, Settlement Management Document Header.
Annotations
Annotations allow metadata, which is evaluated by either the ABAP runtime environment or the relevant SAP framework. The annotations used in a basic view, and the functions they serve, are described as follows:
@AbapCatalog.sqlViewName: '<name>'
Defines the name of the CDS database view. It is limited to 16 characters, and adheres to the following conventions:
ZV_BW<SAP module><type><data type>_<name>
Data types are abbreviated as follows: Attribute = A, Text = X, Hierarchy = H, Transactional = T
@AbapCatalog.compiler.compareFilter: true
Defines the evaluation of filter conditions (i.e., INNER, LEFT OUTER, WHERE) in path expressions.
@AccessControl.authorizationCheck: #NOT_REQUIRED
AccessControl annotations restrict the data returned based on CDS roles, access rules, or conditions.
@VDM.viewType: #BASIC
Defines the category of data represented by values.
@ObjectModel.representativeKey: 'WBELN'
The most specific element of the primary key(s) that represents the entity which the view is based on.
Composite View
This example is a composite view that joins two basic views: one sourced from WBRK, Settlement Management Document Header, and the other from WBRP, Settlement Management Document Item.
Annotations
New annotations and ones that have changed from the basic views are as follows:
@VDM.viewType: #COMPOSITE
Defines the category of data represented by values.
@analytics.dataCategory: #FACT
Tells the analytic manager how to interpret entities. #FACT represents transactional data.
@analytics.dataExtraction.enabled: true
Represents a view that is suitable for data replication.
@analytics.dataExtraction.delta.byElement.detectDeletedRecords
Using this annotation, the system will remember all key combinations of the view that were extracted in delta mode. If a key combination does not occur in the view anymore, this will automatically generate a delete image in the extracted data.
@analytics.dataExtraction.delta.byElement.name: 'AEDAT'
Enables the generic delta extraction. This is the element that should be used for filtering during generic delta extraction. This element can either be a date or a UTC timestamp.
@Semantics.quantity.unitOfMeasure
Defines an element as a quantity field, to which a unit of measure key is assigned
@Semantics.unitOfMeasure
Defines an element as a unit of measure key
Datasource Creation
At this phase of development, the BASIS team will generally hold the responsibility of creating the new ODP connection.
- In the BW Modeling perspective in Eclipse, expand Data Sources > your ODP CDS folder > your ODP connection to S4.
- To create the data source
- Right-click the source system, select New, and then DataSources
- The project should be defaulted to your BW project and the source system to that selected.
- Choose Proposal from Operational Data Provider
- Search for the desired CDS view and select Next
- Give the DataSource a description and select Finish
Subsequent steps follow the standard BW development process.
Conclusion:
From this blog post, you should now understand the prerequisites necessary to write CDS views, and to then source BW extractors with those views.