Technical Articles
Use SAP BTP, Kyma runtime to extend SAP Marketing Cloud
Overview

The above configuration enables access to SAP Marketing Cloud APIs and provides the ability to configure Kyma functions and microservices to be triggered with SAP Marketing Cloud events.
This is achieved thanks to SAP S/4HANA Cloud Extensibility which is a generic way of extending any S/4 system using both Cloud Foundry and SAP BTP, Kyma runtime.
Once the configuration is done, the runtime flow will trigger functions and microservices in SAP BTP, Kyma runtime with SAP Marketing Cloud events. It will also be possible to call SAP Marketing Cloud APIs using the provided credentials.

Prerequisites
- A provisioned SAP BTP, Kyma runtime. Read this blog to get started.
- An SAP Marketing Cloud tenant that will be extended using SAP S/4HANA Cloud Extensibility and SAP BTP, Kyma runtime.
- Quota available for the SAP Enterprise Messaging service on the SAP BTP subaccount on which SAP BTP, Kyma runtime is enabled.
Register the S/4 system (SAP Marketing Cloud)
- Create a system in SAP BTP Cockpit.
- Copy the generated token.
- Create a new Extension in SAP Marketing Cloud under
Maintain SAP Cloud Platform Extensions
and provide the copied token.

- In SAP BTP, add entitlements for SAP S/4HANA Cloud Extensibility to the subaccount in which SAP BTP, Kyma runtime is enabled.

-
- Choose Add Service Plans.
- Select
SAP S/4HANA Cloud Extensibility
. - Select the registered S/4 system from the drop-down menu.
- Select both
messaging
andapi-access
plans. - Save the changes
Enable calling SAP Marketing Cloud APIs
TIP: For details on setting up api-access
for SAP S/4HANA Cloud APIs in the Kyma runtime, see the official documentation on SAP Help Portal.
This section describes how to do the necessary setup in SAP BTP, Kyma runtime to be able to make API calls to SAP Marketing Cloud.
- In SAP BTP, Kyma runtime, access
SAP S/4HANA Cloud Extensibility
in Service Catalog.
- Create a new instance with the
api-access
plan.
In the background, this will:
-
- Set up all the necessary communication arrangements in SAP Marketing Cloud.
- Create the necessary system users to make API calls.
- Set up any other configuration required to make API calls.
NOTE: scenarioId
will depend on the API calls that will be made to SAP Marketing Cloud.
- Bind the created instance to a function or a microservice in Kyma.
The connection configuration will be available as environment variables that can be used by microservices or functions.
/**
* Add this to dependencies
{
"name": "call-mktng-api",
"version": "1.0.0",
"dependencies": {
"axios": "latest"
}
}
*/
const axios = require("axios");
const baseURI = `${process.env['MKTNG_URL']}/sap/opu/odata/SAP/API_MKT_CAMPAIGN_SRV;v=2`
console.log(`baseURI is-- ${baseURI}`);
module.exports = {
main: async function (event, context) {
try {
const response = await axios({
method: 'get',
url: `${baseURI}/Campaigns?$top=2`,
auth: {
username: process.env['MKTNG_User'],
password: process.env['MKTNG_Password']
}
});
console.log(response.data.d.results);
return response.data.d.results
} catch (error) {
console.log(error);
event.extensions.response.status(500).send("Error");
}
}
}
Such a function can either be called internally from other functions or exposed externally via Kyma API Rules and then invoked via the URL
Enable SAP Marketing Cloud events consumption
TIP: For details on enabling the consumption of SAP S/4HANA Cloud events in Kyma runtime, see the official documentation on SAP Help Portal.
Set up EMS clients
In Kyma’s Service Catalog, create the SAP S/4 HANA Cloud Extensibility
instance with the messaging
plan:
- For
systemName
, enter the name of the registered system. - Provide a unique
emClientId
.
It will create the Enterprise Messaging client in the background and set up the necessary communication arrangement. You can verify the created client in the Enterprise Messaging admin UI.
The namespace will look as follows: sap/S4HANAOD/{emClientId}
This Enterprise Messaging client will be receiving the events from SAP Marketing Cloud. To capture and forward the events from this instance to Kyma, you need to create another Enterprise Messaging client.
In subscriberFilter
, provide the same namespace that was created for the SAP S/4 HANA Cloud Extensibility
instance of the messaging
plan. This is done to receive events from that namespace in this Enterprise Messaging client.
Configure events in SAP Marketing Cloud
You now need to configure in SAP Marketing Cloud all event types you wish to send to SAP BTP, Kyma runtime for various extensions.
- In SAP Marketing Cloud, access Enterprise Event Enablement.
- Go to channels list and select the channel with the name
SAP_CP_XF_{emClientId}
- Search and select the events that will be sent.
As an example, I selected sap/s4/beh/marketingpermission/v1/MarketingPermission/*
.
You will see the same events appearing in the EMS admin UI.
Set up an extension in SAP BTP, Kyma runtime
You can now create a serverless function or a microservice that can receive the events from SAP Marketing Cloud via Enterprise Messaging.
These steps show how to create a function, but the flow will be similar if you decide to use a microservice.
To enable secure access, you have an option to set up OAuth2 for the exposed webhook. However, it is not a must to use OAuth2 – customers can always use their preferred authentication mechanism such as basic authentication or any other that works with EMS webhooks.
- Set up an OAuth2 client in Kyma.
Note: The client id and client secret values are by default encoded. Please decode and then copy them to EMS webhook details
- Expose the function with an API Rule.
Configure an Enterprise Messaging webhook
To consume the events, you need to go to the second Enterprise Messaging client that was created and configure the queue and subscription to enable SAP BTP, Kyma runtime to start receiving the events. Then, you need to create a webhook.
- Create a new queue for this EMS client.
- Create a queue subscription.
- Configure the queue subscription by setting Topic to the namespace originally created for the
messaging
instance of SAP S/4HANA Cloud Extensibility.
- Set up the webhook.
- The webhook url is the URL of the API rule created in Kyma runtime to receive events.
- Provide the client id and client secret for the OAuth client client created in Kyma runtime.
- Provide the Token URL. It is of the form
https://oauth2.{kyma cluster domain}/oauth2/token
{"type":"sap.s4.beh.marketingpermission.v1.MarketingPermission.Changed.v1","specversion":"1.0","source":"/default/sap.s4.beh/000000000730096987","id":"+hY+VeskHtuDiNMBjQ0Tgg==","time":"2020-10-12T04:51:30Z","datacontenttype":"application/json","data":{"MarketingPermissionUUID":"fa163e0b-249b-1ee9-b48b-5ab2bab3c4b8","PermissionGranted":"Y"}}


Thank you Gaurav! That´s a very useful guide
Hi Gaurav,
Thank you for a great blog. Please can you advice which release of Marketing Cloud did you use and did you need to do any additional steps to enable the communication scenarion required for the integration with Kyma runtime?
Regards,
Sunita
Hi Sunita,
You can try with 2008 release. Please ensure the user that you logs-in with has enough information to perform administrative actions such as creating "Extensions" and as such.
Hi Gaurav,
We are trying to set up this scenario, however we find we don't have a " Enterprise Event Enablement" app in Marketing Cloud. Are there additional prerequisites which we are missing?
Best regards,
Manuel
Hi Manuel,
You can get in touch with the responsible person for your marketing access. Perhaps appropriate access is missing. Which release version you are on?
Best regards,
Gaurav Abbi
Hi Manuel,
Following the marketing cloud integration guide, you need to do two steps in the Marketing Cloud system
Note, to access the app "Enterprise Event Enablement" you need to extend the business role for the administrator by the corresponding business catalog. If you won't find the catalog, kindly raise a support ticket, that colleague look into, and figure out the root cause for that issue.
Best Regards, Josef