Skip to Content
Technical Articles

SAP S/4HANA: ODP-Based CDS Extractor Creation

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

  1. First, Eclipse IDE should be installed.
  2. Next, SAP ABAP tools should be installed using the following steps:
    1. On the navigation menu, select Help > Install New Software
    2. 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
    3. 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

  1. In the project explorer of the ABAP perspective, right-click and select New > ABAP Project.
  2. Select the system that you wish to work in and proceed through the wizard to connect.

 

View Creation

  1. Under your new ABAP project, either create or navigate to the package you want to work in.
  2. Expanding the package, right-click and select New > Other ABAP Repository Object.
  3. In the creation wizard, search for “Data,” and choose “Data Definition” (DDL).
  4. 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>
    1. View Types:
      1. BASIC = I
      2. COMPOSITE = C
      3. CONSUMPTION = S
    2.  Data Types:
      1. Attribute = ATTR
      2. Text = TEXT
      3. Hierarchy = HIER
      4. Transactional = TRAN
    3. Example: ZCDS_BWFII_WBRP_TRAN

 

Using a CDS view as the source for a BW extractor requires the use of two view types:

  1. Basic views, which are created on database tables and fetch results without redundancies. These views are simply raw data from the source tables.
  2. 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.

 

  1. In the BW Modeling perspective in Eclipse, expand Data Sources > your ODP CDS folder > your ODP connection to S4.
  2. To create the data source
    1. Right-click the source system, select New, and then DataSources
    2. The project should be defaulted to your BW project and the source system to that selected.
    3. Choose Proposal from Operational Data Provider
    4. Search for the desired CDS view and select Next
    5. 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.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.