Skip to Content
Technical Articles
Author's profile photo Mohit Bansal

Part 3: Architecting Complex Real Life Business Scenario on SAP BTP with ease [ Targeting Multiple backend S/4HANA Systems utilizing Principal Propagation ]

This is the final blog of my Blog series “Architecting Complex Real Life Business Scenario on SAP BTP with ease [ Targeting Multiple backend S/4HANA Systems utilizing Principal Propagation ]”. We have discussed so far

  1. Business Requirement in detail and understanding of the Landscape
  2. Technical Architecture & Component Detail

In this blog, We will discussing about complete set up and Technical Building blocks so far with the Cloud Application Programming Model.

Configurations & System Set UpPrincipal%20Propagation%3A%20handshaking%20with%20BTP%20with%20S4HANA%20for%20Logged%20in%20User Principal Propagation: handshaking with BTP with S4HANA for Logged in User

Identity Propagation

Apart from the common setup which we have discussed in my last blog, most important stuff is the correctly set up for the Principal Propagation.

Principal Propagation works like a charm to pass the identity of “Logged In User”.

Authorization Control at Backend

Thanks to ABAP CDS with  Backend API with strong Access control have saved life to control the backend authorization to S4HANA Backend.

Once the Cloud Connector and PP configuration done by administrator , Please create the destinations for each S4HANA system , say A, B..N


Principal Propagation Configuration

Use case specific Configuration

Again, Quick recap, In our Use Company Code is the main deriving factor, Two Important Points to be noted based on the detailed requirement discussed so far:

  1. User have access to multiple company codes across multiple system.
  2. Company Code is unique across all system.

so, we need to design our solution, we need

  1. One Config Table where we can map company codes against each system [ each system will be represented by BTP Destination set up above]
  2. So for any external API call to S4HANA system for fetching  information[ Business partner, Accounting Document  etc.] we will pass below two attributes :

a) Logged in user Information which will control Authorization[ will be taken care by Principal Propagation]. no need to pass, framework is smart 🙂

b) Selected Company Code, Yes this we will pass in Query filter.


Configuration Table for Company Code

End to End Detail Technical Picture with sample Data 


End to End Technical flow with sample data

once the User will select the Company Code, OData Service will be triggered created on the top of this table which will used to derive the destination dynamically.

CAPM Application Logic Flow & Development 

with this Blog, I won’t be repeating the CAPM development approach, Pleas refer CAP documents for the basic CAP understanding.

Pre Requisite: 

  • Connectivity is available with all respective Backend Systems:
    • Cloud Connector Setup is done
    • Destinations Setup is done as mentioned above.
  • In this use case, all the subsequent data will be retrieved from the Backend like Business partner, Accounting Document, Purchase contract etc. so either CDS based standard or custom API are available. Standard APIs can be referred from the API Hub

CAPM Logic Flow


CAPM Logic Flow


Explanation with Code

//Steps:Custom Entity ZI_BusinessPartner / can vbe used Standard API_BusinesspartnerSRV
const cds = require('@sap/cds')

// Glbal attribues can be used across all entities
var global = {};

module.exports = cds.service.impl(async function () {
//Step1: Implement Service Handler
    this.on('READ', 'ZI_BusinessPartner', async (req) => {
//Step2:Retrieve the Destination from Company Code API Call and set in Request Header
    global.dest = req.headers['Destinatination'];
// Step:Call to Backend API    
    const service = await;
// Step4:Return Data
    return service.tx(req).run(req.query);


Reference Package.json : cds.require section

 "cds": {
        "requires": {
            "db": {
                "kind": "hana",
                "pool": {
                    "acquireTimeoutMillis": 5000,
                    "min": 0,
                    "max": 400,
                    "fifo": true
            "uaa": {
                "kind": "xsuaa"
            "ZDemo_SRV_PP_100": {
                "kind": "odata-v2",
                "credentials": {
                    "destination": "S4HANA_100",
                    "path": "/sap/opu/odata/sap/ZDEMO_SRV_PP_100",
                    "forwardAuthToken": true
            "ZDemo_SRV_PP_200": {
                "kind": "odata-v2",
                "credentials": {
                    "destination": "S4HANA_200",
                    "path": "/sap/opu/odata/sap/ZDEMO_SRV_PP_200",
                    "forwardAuthToken": true
        "auth": {
            "passport": {
                "strategy": "JWT"
        "hana": {
            "deploy-format": "hdbtable"

I hope, every one enjoyed this series. I tried to explain from the Business requirement perspective. even though actual coding was bit less because of strong CAPM framework but extremely powerful to solve complex Business Problem with ease.

I keep sharing and posting latest happenings on my LinkedIn, Happy to connect over my LinkedIn too.

Email Id

LinkedIn : Mohit Bansal



Mohit Bansal






Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Martin Pankraz
      Martin Pankraz

      Thanks for spreading the word about SAP Principal Propagation Mohit Bansal! For completeness I am linking here a write up on the solution path with a corporate IDP like Azure AD. Many customers at least have the proxy requirement with SAP Cloud Identity Services or the XSUAA.



      Author's profile photo Mohit Bansal
      Mohit Bansal
      Blog Post Author

      Thanks Martin.

      Author's profile photo Mio Yasutake
      Mio Yasutake

      Hi Mohit Bansal,

      I am interested in the use case you provided. Thanks for sharing it.

      With your solution, do you have to update package.json at cds.requires section if a new company (destination) is added?

      Author's profile photo Mohit Bansal
      Mohit Bansal
      Blog Post Author

      Thanks Mio Yasutake.


      I have updated the reference package.josn code.



      Mohit Bansal

      Author's profile photo Ravi Kumar Gon
      Ravi Kumar Gon

      Great series of blogs, excellent job.

      BR, Ravi Kumar G

      Author's profile photo Mohit Bansal
      Mohit Bansal
      Blog Post Author

      Thanks Ravi for your feedback. Good to hear you liked it.

      Author's profile photo Alok kumar
      Alok kumar

      Hi Mohit,

      Very Informative Blogs .

      If Possible please share Git Repo .