Skip to Content

Overview of Data Replication in S/4HANA Cloud

In the S/4HANA Cloud environment, data can be replicated with these three options:

  • Whitelisted APIs
  • Legacy APIs
  • Data Models

Whitelisted APIs

SAP provides whitelisted APIs (on the SAP API Business Hub) that can be consumed either as ODATA or SOAP services. Data replication is a pull mechanism in which a user triggers the replication. Detailed documentation is available to facilitate a search for the required APIs.

Legacy APIs

SAP delivers legacy APIs using BAPIs and IDOCs. These APIs are primarily used for SAP to SAP based integrations.

Data Models

Data from S/4HANA systems can be replicated to SAP Cloud Platform systems via an automatic or manual provision using CDS views.

The Replicate CDS Views application is based on data model replication and can be used to replicate data from an S/4HANA system to an SAP Cloud Platform system using CDS views. This gives a customer access to data on the distributed systems in the central SAP Cloud Platform system. This facilitates business analysis of  data mart scenarios.

You can also create analytical applications by developing an OData service based on the replicated CDS views. For analytics, a key user can create Calculation views to manipulate data based on the replicated CDS views. An OData service can be used to project the data in the UI.

For more details, please see this.

Why do we need HANA CDS Wrapper views?

Calculation views that are based on replicated CDS views often become invalid when fields are extended. Field level extensibility such as a change in the data type or length of a field results in an invalid Calculation view and the generated reports do not reflect correct data.

To overcome this, a HANA CDS view can be created as a wrapper for the replicated CDS view (router view). The HANA CDS wrapper view abstracts the underlying router view so that the Calculation view is unaffected by fields that are extended as it is based on the wrapper view.

A HANA CDS wrapper view is generated using the deploy.js program (which is a Node.js program). The deploy.js app uses the metadata of a replicated CDS view and generates the definition for a HANA wrapper view and a synonym file.

These sections detail the steps required to generate a HANA CDS Wrapper view.

Generating a HANA CDS wrapper View

These files are generated by the deploy.js program

  • HANA Database Data Definition (.hdbdd) file
  • Synonym file (.sql) using the metadata of a replicated CDS view

Note: You must download the metadata of a replicated CDS view using the Replicate CDS Views app.

To generate the definition and synonym files for a router view, follow these steps:

  • Download and install the Node.js application.
  • Open the Node.js command prompt.
  • Download the ZIP file attached to the SAP note 2589286.

The WrapperGeneratorDeploy folder contains the deploy.js application that generates the definition and synonym files for a router view.

  • Download the metadata (JSON) file using the Replicate CDS Views app and copy the downloaded file to the Input folder.
  • At the prompt, run the CD command to change to the WrapperGeneratorDeploy folder. For example,Prompt>cd <drive>:<path>\WrapperGeneratorDeploy
  • Run the deploy app using this syntax:
    node deploy <source schema> <target schema> <CDS view name>
    where
    <source schema> is the schema in which the router views are created in SAP Cloud Platform
    <target schema> is the schema in which the HANA CDS wrapper views are created in SAP Cloud Platform
  • A confirmation message stating the successful creation of the HANA CDS view definition and synonym file is displayed.
  • The HDBDD (HANA CDS view definition) file is available in the Output folder and the SQL (synonym) file is available in the Synonym folder.

Deploying a HANA CDS wrapper view

To deploy a HANA CDS wrapper view on the target schema, follow these steps:

  • Create a package for a HANA CDS wrapper view
  • Create a target schema
  • Create a synonym file in the target schema
  • Create a definition file in the target schema

To create a package for a HANA CDs wrapper view

  • Log on to the SAP Cloud Platform system with your P user credentials
  • On the home screen, choose CATALOG.
  • Expand the Views folder in the replicated view schema.
  • To see the data in a view, open a view and choose the Open Content
  • To create a package for the HANA CDS wrapper view, choose EDITOR on the home screen.
  • From the Content context menu, choose New > Package
    The Create Package dialog opens.
  • Enter a package name and choose Create.

To create a target schema

  • Choose CATALOG on the home screen. In the left side panel, right click anywhere and choose New > Schema.The Create new Schema dialog opens.
  • Enter a schema name and choose OK.

To create a synonym file in the target schema

  • On the home screen, choose Editor.
  • From the context menu of the replicated target schema (XXXX_WRAPPER_TEST), choose a new file or import a file.
  • Enter a name for the new SQL file
    For example, I_COSTCENTER.sql
  • Copy the content of the generated (output of the WrapperGenerator.js program) synonym file to this new file, I_COSTCENTER.sql

Note: If you import the generated synonym file, you can skip this step.

  • Save and choose Run (F8) to run the synonym file. The synonym file is generated in the Synonyms folder in the target schema XXXX_WRAPPER_TEST.

To create a definition (HDBDD) file in the target schema

  • From the context menu of the target schema, create a new file or import the generated HDBDD (output of the WrapperGenerator.js program) file.
  • Enter a name for the new HDBDD file and choose Create.For example, I_COSTCENTER.hdbdd

Note: If you import the generated definition file, you can skip this step.

  • Enter the following information in the HDBDD file:
  1. namespace (the package created in the target schema)
  2. schema (schema name of the HANA CDS wrapper view created in the target schema)
  3. context (same name as the HDBDD file)
  • Copy the generated HANA CDS wrapper definition (output of the WrapperGeneratorDeploy.js program) file and paste it in the context braces
  • Save and choose Run (F8) to run the HDBDD file.
    The wrapper view is generated in the Views folder in the target schema XXXX_WRAPPER_TEST.
  • Open the wrapper view and choose Open Content to see the data.

We have successfully deployed a CDS View in the SCP System and also have seen its content. Hence, by creating a HANA CDS Wrapper View, we can preserve the consistency of the replicated CDS Views in the SCP System.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply