Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
VinayBhatt
Product and Topic Expert
Product and Topic Expert

Introduction

In this article I will share some experiences of using a custom CDS view on MARA table in S4HANA (onpremise SAP_BASIS 755) and consuming it in SAP Datasphere (version 2024.2.79) for delta enabled replication (Change Data Capture). I will showcase the following : 

  1. Create a Custom CDS view using ADT ( Abap Development Tools) in Eclipse Studio. 
  2. Define CDS annotations for "dataExtraction" and "changeDataCapture".
  3. Consume the CDS view in Datasphere using "Initial plus Delta" option. 
  4. Create a new Material master in S/4HANA & see the updated delta in SAP Datasphere. 

Prerequisties 

Please note before using any CDS view from S4HANA for replication in Datasphere you should ascertain that data replication prerequisites are installed in the S4HANA system. Please refer the following sapnote : 

SAP ABAP Integration Central note

Note : It is recommended to use a standalone SLT server for replicating Tables from S4HANA into datasphere as highlighted in the Abap Integration Central note. 

highly recommend reading this excellent blog post by Simon - CDS based data extraction - Part II Delta Handling.

This blog presents conceptual understanding on the two common mechanisms of capturing Delta and the core concepts around Delta Handling : 

  •  Generic Date/Timestamp Delta

 

 

:{
  dataCategory: #FACT,
  dataExtraction: {
	enabled: true
	delta.byElement: {
	   name: 'LastChangeDateTime'
	   }
    }
  }

 

 

  • Change Data Capture Delta

 

 

:{
    dataCategory: #DIMENSION
    dataExtraction: {
       enabled: true,
       delta.changeDataCapture: {
	 automatic : true
         }
      }
}

 

 

1. Create a Custom CDS View : ADT on Eclipse 

First step here is to install Eclipse Studio & Abap Development tools(ADT) plugin on the Eclipse Studio. Follow the SAP Development Tools page for detailed instructions.

You can also follow instructions from developers tutorial to install ADT.

  • Create new Abap Project and connect to your S4 system
  • Create new Abap Repository Object 

VinayBhatt_1-1706841603575.pngClick on the drop down for Core Data Services and click on Data Definitions : 

VinayBhatt_0-1706853710436.png

Choose a name for the object and then select a Referenced Object from the data dictionary , this can be another CDS view or other Objects like a physical table. Here I have selected MARA table : 

VinayBhatt_3-1706841771126.png

Fill a change request : 

VinayBhatt_4-1706841816285.png

Here we select a Template view : Define View , this step will generate the CDS code along with needed annotations and also using the selected Referenced Object and its data structure for example MARA table will have many different Fields/Columns, all of these will be available to use in the CDS view 

VinayBhatt_5-1706841846630.png

As we see below the CDS code is generated , enter a name for the SQL view and note here that all needed Fields can be selected and new label names can be assigned to standard fields for example : ERNAM field contains name of the person who changed the entry, we can assign a better label here if needed. 

Also note we can use Where clause here to futher filter the data, please follow the developer guide linked above which contains detailed steps.

VinayBhatt_6-1706842140215.png

2. Define CDS annotations 

Put in below annotations for "dataExtraction" and "changeDataCapture" :

 

 

:{
  dataCategory: #FACT,
  dataExtraction: {
    enabled: true,
    delta.changeDataCapture.automatic:true
    
    }
  }

 

 

This is how the CDS view looks now : 

VinayBhatt_7-1706842278214.png

Save & Activate the View.

Right click the view to change the API state

VinayBhatt_8-1706842419437.png

VinayBhatt_9-1706842507337.png

VinayBhatt_10-1706842572863.png

VinayBhatt_11-1706842593976.png

3. Consume the CDS View in SAP Datasphere

In SAP datasphere goto the Data Builder & Click on new Replication flow.

VinayBhatt_12-1706842844119.png

VinayBhatt_13-1706842918270.png

Select source connection & from the drop down select your S4 HANA system connection.

VinayBhatt_14-1706842975458.png

Select CDS as "container".

VinayBhatt_15-1706843079929.png

Select the CDS view developed in Eclipse : 

VinayBhatt_16-1706843139743.png

Click Add Selection : 

VinayBhatt_17-1706843171456.png

Go to the Settings Tab, here you can now see the Delta Option Available : 

VinayBhatt_18-1706843237137.png

Select Delta load Frequency

VinayBhatt_19-1706843308198.png

Select a Target - in this case I have selected a Table in Datasphere, Table name is by default the same as the source name. Finally, give a name fo the Replication Flow (Business Name and Technical Name): 

VinayBhatt_0-1706845211703.png

Save & Deploy the Replication view : 

VinayBhatt_1-1706845307674.png

VinayBhatt_2-1706845400612.png

VinayBhatt_3-1706845519960.png

Run the Replication Flow : 

When we run the Replication flow the first step is that the Initial load will be started and then based on the delta load frequency a subsequent run will start to copy over the delta.

VinayBhatt_1-1706846212977.png

Monitor the Run

Here we can monitor the Initial Load progress and also check for any errors being reported.

VinayBhatt_2-1706846312004.png

Initial load has finished & now the Replication flow waits for the next Delta run, which will depend on the Frequency selected during the configuration of the Replication Flow : 

VinayBhatt_3-1706846534350.png

VinayBhatt_4-1706846599787.png

4. Create a new Material master in S4HANA

Now we create a new Material in S4HANA and wait for it to be replicated in SAP Datasphere table using the replication flow that we have deployed. 

VinayBhatt_6-1706847114157.png

VinayBhatt_7-1706847202129.png

Replication Flow in Datasphere will start the next run to consume the delta in few mins, but lets check the data in the Replicated Table and filter with this new Material Record : 

VinayBhatt_8-1706847497379.png

Filter the new record : 

VinayBhatt_9-1706847558418.png

The New Material is not available yet, let's wait for the delta run ( 05:00 UTC time as seen previously ) : 

VinayBhatt_10-1706847631800.png

New Delta Run was performed at 05:00 UTC : 

VinayBhatt_0-1706851537802.png

Let's look at the record in the replicated Table and as we see below the new data record is now available : 

VinayBhatt_1-1706851793958.png

Conclusion

This article is an attempt to showcase the various features available in SAP Datasphere and also how some of the S4 CDS views (extraction enabled) can be consumed in SAP Datasphere. Please note the CDS based extraction will be limited based on the S4 version being used and the scenario/tables being used.

This article only covers an example scenario from S4HANA onpremise system (SAP_BASIS 755).

5 Comments