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.
Showing results for 
Search instead for 
Did you mean: 

In this blog post, you will learn how an event from SAP Cloud for Customer could initiate an instance in your SAP Cloud Platform Workflow Service using a SAP Cloud Platform Integration as middleware.

The use case is as following:

In SAP Cloud for Customer a sales employee set a sales quote to won, this should initiate a workflow and transfer specific quote information like items (products, prices, quantity) but also header information like account and description.

So, let’s get started.

Configuration in SAP Cloud for Customer:

  1. Create an event notification in SAP Cloud for Customer:

Therefore, go to the work center Administrator à General Settings and open “Event Notification”.

  • Add a new consumer and define the endpoint of your iFlow. As soon as your iFlow is deployed you could find it in the SAP Cloud Platform Integration --> Monitor --> Manage Integration Content: Select your iFlow and on the right side you will see the endpoint.

  • Edit the event credentials and choose as authentication method “SSL Client Certificate”. A system key pair will be created and you could download the public key.

  • Add subscriptions in the table below. In the above mentioned use case a C4C event should get triggered as soon as a sales quote is set to won. Therefore, three subscriptions will be created:

Business Object Node Field Changed Field Name Field changed from Field changed to
Sales Quote Root X Progress 1 – Not Relevant 3 - Won
Sales Quote Root X Progress 2 - Pending 3 – Won
Sales Quote Root X Progress 4 - Lost 3         - Won

  • As a last step, activate your consumer. The result will look like this:

C4C Event Configuration

2) Set a sales quote to won, to trigger the event. As a result, you will find an entry in the event monitor (Administrator --> General Settings --> Event Notification Monitoring):
"event-type": "SalesQuote.Root..PendingToWon",
"event-type-version": "v1",
"event-id": "00163e69-e86e-1eda-bbef-ff6fbd5146d9",
"event-time": "2020-09-05T13:59:13Z",
"data": {
"root-entity-id": "00163E69E86E1EEAB9D73CEA9E5C5F44",
"entity-id": "00163E69E86E1EEAB9D73CEA9E5C5F44"

This event provides the information which event was triggered and sends over the quote GUID.

iFlow Configuration in SAP Cloud Platform Integration:

The iFlow logic is as following: The C4C event gets send to the iFlow where it will be converted from JSON to XML. This is needed so that the quote GUID could be saved in the content modifier as a property and be used in the GET call to C4C to retrieve further quote attributes/information. This message is flowing into a message mapping where it is mapped to the workflow structure. The outcome is in XML. This must be converted to JSON. Again, a content modifier is needed to provide a content-type in the header of the message and now, it could be sent over to SAP Cloud Platform Workflow Service.

iFlow Overview

Let’s do it step by step:

1) Configure your inbound channel:

Use a HTTP channel and upload the downloaded public certificate from your SAP Cloud for Customer consumer. Provide an iFlow address. The SAP Cloud Platform Integration will add /http/ in between the CPI hostname and iFlow address during the deploying step, so that the iFlow endpoint will be:

iFlow Inbound Channel

2) Add a XML to JSON converter and choose that a XML root element should be added.

JSON to XML Converter

After this step, the message looks like this.
<?xml version='1.0' encoding='UTF-8'?>

3) Now, let’s save the quote GUID as a property. There, you could use the type XPATH and as value enter the path from the entity-id.

Save Quote GUID as Property

4) In the request-reply step, a GET call to the C4C system will be triggered:

Make sure, that you filter for your specific quote in the query options:

GET C4C Quote

&$filter=ObjectID eq '${property.Quote_GUID}'

GET C4C Quote Details

The result message looks like this:
<Description>Item 1</Description>
<Description>Item 2</Description>
<Name>Angebotshülle V1</Name>


5) The WSDL from the C4C message gets created automatically and you could use it in your message mapping. The C4C structure looks like this:
...Item Information...
...header information...

For the workflow, the structure must be like this:
"definitionId": "string",
"context": {}

You could find a detailed documentation on the provided APIs for Workflow Management here.

The definition id is the created workflow definition and the context could be design individually. For this use case the structure should be like the C4C one.

I created an XSD with the help of an online tool.

6) SAP Cloud Platform Workflow Service is expecting the message in JSON. Therefore, an XML to JSON converter is used to format the message. Make sure to suppress the JSON root element, as this is not expected from the SAP Cloud Platform Workflow Service.

XML to JSON Converter

7) Use a content modifier for defining the Content-Type as “application-json”.

Content Modifier with Content-Type

8) Now, the message is ready to be send over to SAP Cloud Platform Workflow Service. Use a HTTP channel and define the address like this:

iFlow Outbound Channel

As credential use OAuth2 Client Credential. For this, create it in Monitor à Manage Security Materials. The Token Service URL could be found in the screenshot of the SAP Cloud Platform Cockpit below.

oAuth2 Credential

You will find all SAP Cloud Platform Workflow Service information like service URL and token information (token URL, client ID, client secret) in the SAP Cloud Platform Cockpit:

SAP Cloud Platform Cockpit

View result in SAP Cloud Platform Workflow Service:

Go to Monitor Workflows --> Workflow Instances and you will find your send message.