Skip to Content
User Experience Insights
Author's profile photo Martin Boeckling

ABAP CDS replication in SAP Data Intelligence

ABAP CDS views as data models take a major part in the ABAP environment and help defining contents within a HANA based system. As a beginner in the ABAP Integration world within SAP Data Intelligence it is sometimes not easy to find fast the right information in one place. What really helped me at the beginning is the starting blogs about ABAP integration which can be found here. To now provide people who have or had similar problems like me regarding the replication of self-created ABAP CDS-Views, I will provide in this blog a step-by-step guide to create your own ABAP CDS view from a SAP S/4HANA and then replicate this ABAP CDS view to a wiretap.

In this blog I will introduce to you the eclipse environment with the ABAP development tool add-in and the possibility to replicate your own created ABAP CDS view over SAP Data Intelligence.

Requirements

To fulfill this blog, you need an Eclipse environment, an  SAP S/4HANA environment, an SAP Netweaver and a SAP Data Intelligence environment. To get started to create your own ABAP CDS-view, it is necessary to set up your own Eclipse environment. First, we have to download Eclipse, which can be downloaded from here. After you set your environment, it is necessary to install the ABAP development tool, shortly called ADT. The procedure for the installation can be accessed here.

Creation ABAP CDS view

Connection setup in Eclipse

After you now setup the ADT environment in Eclipse, we now come to the step to create an ABAP CDS view. First, we need to establish a connection between the Eclipse environment and the SAP S/4HANA system. To establish the connection, you must click with your right mouse clicker in the project explorer field:

Eclipse overview screen

On the opened context menu in Eclipse, we now select under the entry New the entry ABAP project. After we selected this entry, you can now see a list of already connected systems from your SAP Logon environment. Select your system you want to connect with.

System%20connection%20overview

System connection overview

After then click on the Next button to come to the next overview, in which the different connection parameters are listed. Check if all parameters match your connection information and if so, click on the Next button. Enter now your credentials from the system you want to connect with to connect to the system. Now click on the Finish button to finalize the connection to your Eclipse environment.

After we now connected to the SAP S/4HANA system, we are now able to create or access f.e. ABAP objects from the SAP S/4HANA system. As we in this tutorial want to create our own ABAP CDS view, we will look in the next chapter at the procedure to create an ABAP CDS object. We now right click on the created entry and click in the popup window on the button ABAP Repository Object.

ABAP CDS view definition

After we clicked on the ABAP Repository Object button, we get now the following overview of different possibilities we have from this endpoint. As we now want to create an ABAP CDS View, we are going to expand the Core Data Services section and click on the entry data definition.

Possible%20ABAP%20repository%20objects

Possible ABAP repository objects

When we click on the Next button, we need to give the data definition a name, a description and it needs to be assigned to a package. In our example, we are going to assign to the temporary package $TMP. We name the ABAP CDS View Z_COMPANY_CODE_01 and a description like Company Code Replication.

CDS%20view%20name%20definition

CDS view name definition

We now click two times on the Next button and get the overview with the possibility to select different templates. In the next window we see different templates from which we select the Define View template.

Selection%20of%20data%20definition

Selection of data definition

We now get the following overview with the Annotations displayed in blue color.

CDS view initial overview after creation

In the first line of the now created ABAP CDS view, we need to specify the SQL view name to name the corresponding CDS database view to our self-created CDS view. The limit for such names is restricted to 16 characters. An example of a possible SQL View Name could be ZCOMCODE_01. After entering the SQL View Name, it is now necessary to define the annotation of the ABAP CDS view. On the SAP Help Portal, you can find the possible annotations that can be defined in the ABAP CDS view. For the created ABAP CDS view we are going to use the tables t0001 and tka02 as tables for the ABAP CDS-view. The t001 table stores company codes and can be used to create a CDS-view. The tka02 table stores controlling area assignment data. We are going to join the two tables over the field bukrs and perform a left outer join with the table tka02 and use t001 as the main table. Furthermore, the field bukrs from the table t001 will be used as a Representative Key Field. The difference between a Key Field and Representative Key Fields is explained on this SAP Help Portal site. The definition of the ABAP CDS view is as followed:

define view Z_COMPANYCODE_01 as select from t001
    left outer to one join tka02 on tka02.bukrs = t001.bukrs {
    key t001.bukrs as CompanyCode,
    t001.butxt as CompanyCodeName,
    t001.land1 as Country,
    t001.waers as Currency,
    t001.ort01 as Place,
    tka02.gsber as BusinessArea
}

To now enable the replication of the created CDS view, there is the need to enable on the first hand the replication and on the other hand enable the delta Capturing of the CDS view to really be able to replicate the created CDS view. When CDS views do not have the annotation defined, they throw an exception in the SAP S/4HANA application log (Transaction SLG1). If both annotations are missing, the message ‘CDS view Z_COMPANY_CODE_01 is not extraction-enabled’ appears in the log. If the annotation for the delta data capturing is missing, the message ‘CDS View is not enabled for replication, only initial load is possible’ appears in the application log. The needed structure for the deltachangeDataCapture annotation added with some deeper background information is explained in the blog of Simon Kranig under the following link or the SAP Help Portal site.

After the implementation of the respective annotation, the created CDS view looks like the following:

@AbapCatalog.sqlViewName: 'ZCOMCODE_01'
@AbapCatalog.compiler.compareFilter: true
@Analytics:{
   dataCategory: #FACT,
    dataExtraction: {
        enabled: true,
        delta.changeDataCapture: {
            mapping:
            [   {table: 'T001',
                role: #MAIN,
                viewElement: ['CompanyCode'],
                tableElement: ['bukrs']
                },
                {table: 'TKA02',
                role: #LEFT_OUTER_TO_ONE_JOIN,
                viewElement: ['CompanyCode'],
                tableElement: ['bukrs']
                }
            ]
        }
    }
} 
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Company Code Replication'
define view Z_COMPANY_CODE_01 as select from t001
    left outer to one join tka02 on tka02.bukrs = t001.bukrs {
    key t001.bukrs as CompanyCode,
    t001.butxt as CompanyCodeName,
    t001.land1 as Country,
    t001.waers as Currency,
    t001.ort01 as Place,
    tka02.gsber as BusinessArea
    
}

SAP S/4HANA CDS view lookup

After creating the ABAP CDS view, we are now able to look at our created ABAP CDS view in our SAP S/4HANA system. To access our ABAP CDS view, we need to search in the transaction se12 with the defined sqlViewName of our created ABAP CDS view, in my case it is the name ZCOMCODE_01. The ABAP CDS view is structured in the following way:

CDS%20view%20structure%20overview%20in%20S/4HANA

CDS view structure overview in S/4HANA

The created ABAP CDS view can also be displayed in the SAP Data Intelligence Metadata Explorer. A detailed introduction and walkthrough through the functionalities of the metadata explorer is outlined in the blog of Pavan Kumar Parepalli. After navigating to the created ABAP CDS view the data preview within the metadata explorer of the created CDS-view shows following result:

CDS%20view%20in%20Data%20Intelligence%20Metadata%20Explorer

CDS view in Data Intelligence Metadata Explorer

Replication ABAP CDS view

SAP Data Intelligence Modeller overview

To now replicate the created ABAP CDS view, we jump into the SAP Data Intelligence system and access the modeler environment, in which we can create our pipeline. We then see the following overview:

SAP%20Data%20Intelligence%20operator%20overview

SAP Data Intelligence operator overview

On the left side the user has the possibility to switch between different tabs, f.e. for predefined or stored pipelines or, as you can see in this picture, about the different available operators. The important operators in our case are the ABAP operators. To now put an operator in a pipeline, we must create a pipeline by clicking on the plus in the upper right corner of the left window. We give then the pipeline a unique name and store the created pipeline. After creating the pipeline, we can set up our pipeline with different operators. In our case we will use the ABAP CDS Reader and the Wiretap operator to look at our transferred data.

Pipeline setup

We therefore need to specify the ABAP Connection to tell the operator to which connection he should communicate, determine the version of the Operator ( in our case we used the V2 Operator as it transfers a message output and we do not need the ABAP conversion operator) and specify the name of the ABAP CDS view we want to replicate. The overview of the different available versions can be found under the documentation of the ABAP CDS reader documentation.

ABAP CDS operator

To extract the correct ABAP CDS view we must specify the ABAP CDS Name. As outlined in the official documentation, the SAP Data Intelligence system needs to have the necessary authorization or the ABAP CDS view is part of an allowlist. If this is not the case, the ABAP CDS view can not be used for replication. In the below list you can find the exact specification of the ABAP CDS operator:

  • Label (Name of Operator): ABAP CDS Reader V2
  • ABAP Connection (Connection to e.g. S/4HANA System): S4_RFC_TechEd
  • Version (Version of operator (difference in output)): Version 2
    • Version 0: Output type abap.*
    • Version 1: Output type abap.*
    • Version 2: Output type message.*
  • Subscription Type (Selection between new and existing): New
    • Select new if the CDS view is replicated for the first time
    • Select existing if the CDS view was already replicated
  • Subscription Name (Name of the subscription): CDS_Replication
    • For Subscription Type new user has to name subscription
    • For Subscription Type existing the user can select the subscription IDs for stopped graphs
  • ABAP CDS Name (Name of ABAP CDS view): Z_COMPANY_CODE_01
  • Transfer mode (Selection of transfer mode for CDS view): Replication
    • Initial Load: initial load only
    • Replication: replication of delta information of object including initial load
    • Delta Load: replication of delta information only
  • Records per roundtip (Chunk size of records per roundtrip (range from 0-1,000,000)): 1000

After we defined the ABAP CDS Reader, we can enter the operator in which we can see our results, the Wiretap operator. An exact explanation of what the different customization possibilities mean can be found on the following SAP Help Portal page. For our purposes, we leave the default settings.

SAP%20Data%20Intelligence%20pipeline%20setup

Wiretap operator

After we completed this graph, we save our pipeline and can run our graph by clicking on the execute button.

CDS replication

SAP%20Data%20Intelligence%20pipeline%20setup

SAP Data Intelligence pipeline setup

When the graph is successfully running, the replicated ABAP CDS view transfers it output to the wiretap and is then displayed in the corresponding UI of the wiretap operator.

Wiretap%20output

Wiretap output

To extend the pipeline there is also the possibility to replicate the ABAP CDS view into an object store like S3 by using the Write File operator. A detailed documentation for the operator can be found here. Furthermore the user has also the possibility to process the data and join the data with a different data table.

Good to know

To debug why a Graph failed we can use for a SAP S/4HANA source system the functionality of the application log (Transaction SLG1). After specifying in which time range the error occured, the user has the possibility to check if the name was misspelled or authorization issues are the reason for a failing.

I encourage you to try out different ways of building your ABAP CDS view by f.e. using Associations instead of Joins. Check therefore this blogpost out from Sanjeev Kumar where he talks about the difference between Joins and Associations.

Assigned tags

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