Integrate SAP S/4HANA Cloud with SAP Emarsys Customer Engagement (2023)

In this blog post, we describe a possible approach to replicate contact and sales data from SAP S/4HANA to SAP Emarsys Customer Engagement. The content described is created individually and is not part of a ready-made SAP integration.
The described integration scenarios can be used as a template to create a custom integration with SAP S/4HANA and SAP Emarsys Customer Engagement. SAP Cloud Integration is used for message transformation for API-based data imports to Emarsys.

The following diagram depicts the high-level setup of an example integration between SAP S/4HANA and SAP Emarsys Customer Engagement using SAP Cloud Integration.

Integrate SAP S/4HANA Cloud with SAP Emarsys Customer Engagement (1)

This blog post does not cover importing product data into Emarsys.
For information on uploading product data to Emarsys, refer to the Emarsys help documentation.


Products/solutions/services used:

  • SAP S/4HANA in the cloud or on premises
  • SAP Cloud-Integration (SAP Cloud Integration Suite)
  • SAP Emarsys Customer Loyalty
  • SFTP server for product data (not covered in this blog post)

integration overview

In this blog post, we will focus on replicating B2C Sales Orders/Contacts and B2C Trading Partners.
As of now (Q2 2022), SAPEmarsysCustomer Engagement does not offer a public API to import product data.

Before loading data, familiarize yourself with the available data objects and their corresponding fields and data types.

Integrate SAP S/4HANA Cloud with SAP Emarsys Customer Engagement (2)

Trading partner replication

  • Emarsys Documentation - Contact Data Fields Overview
    https://help.emarsys.com/hc/en-us/articles/115004637605-Overview-Contact-data-fields-Overview
  • Emarsys Documentation - Upload your contact details
    https://help.emarsys.com/hc/en-us/articles/213706389-Uploading-your-contact-data
  • SAP S/4HANA Outbound Service: Trading Partner Replication via SOAP Web Service
    • It is recommended to collect and send messages in batches
    • Only relevant trading partners should be replicated to Emarsys
  • Emarsys-API: Kontakt-API
  • IFlow: contact data replication
    • Process SOAP message received from SAP S/4HANA
    • Converts the incoming SOAP message request into an Emarsys contact API request
    • Message processing errors send notification to the defined tenant admin via aEmarsys Broadcast-Event.
      Exception handling is described in this blog post "IFlow error notification"
    • Messages received with errors are written to the SAP Cloud Integration data store for reprocessing.
  • IFlow: Contact Data Processing 1
    • The failed SOAP message was reprocessed and the failed message was resubmitted to the contact data replication IFlow.
    • If the message fails again, the entry is removed from the datastore and moved to another datastore for a second reprocess.
  • IFlow: Contact Data Processing 2
    • The failed SOAP message was reprocessed and the failed message was resubmitted to the contact data replication IFlow.
    • If the message fails again, the entry is removed from the datastore and moved to another datastore for verification.
    • Entries in the datastore for verification are not processed again.

customer order replication

  • Emarsys Documentation: Prepare Your Sales Data File
    https://help.emarsys.com/hc/en-us/articles/360003070654-Preparing-your-sales-data-file
  • Emarsys Documentation: Upload Your Sales Data
    https://help.emarsys.com/hc/en-us/articles/213706429-Uploading-your-sales-data
  • SAP S/4HANA Outbound Service: Customer Order Replication via SOAP Web Service
    • It is recommended to collect and send messages in batches
    • Only relevant customer orders need to be replicated in SAP Emarsys Customer Engagement.
      Custom filters can be set up in SAP S/4HANA to control sales orders replicated to receiving systems.
  • IFlow: replication of customer order data
    • Process SOAP message received from SAP S/4HANA
    • Converts the incoming SOAP message request to an Emarsys Sales Data API request
    • Message processing errors send an Emarsys broadcast event notification to the defined tenant admin

Product data replication

(Video) SAP Emarsys Customer Engagement Services

A secure connection is established between SAP S/4HANA and SAP Cloud Integration.
Follow the SAP S/4HANA setup guide to integrate SAP S/4HANA with SAP Marketing Cloud as the same outbound services are used for this integration.

It is recommended to apply custom filters in SAP S/4HANA to replicate only relevant data, this is especially important for sales data replication.
Also, you should consider batch data replication for better performance.

Configuration Guides for SAP S/4HANA Integration

SAP S4/4HANA Setup Overview

Summary of configuration steps.

  • Configure a secure connection between systems
  • Configuration in SAP Cloud Integration
    • The endpoint created and the communication used must be maintained in SAP S/4HANA
  • Configuration in SAP S4/4HANA
  • Scenarios to configure:
    • Trading partner replication
      • Endless Purpose (EOP) for Business Partners
      • No business partner relationship
    • customer order replication
    • No product replication directly from S4HANA. SOAP WS sends partial product catalog updates instead of the entire catalog as a full extract
  • Initial data load from SAP S/4HANA
    • First data upload for trading partners
    • Entry fee for customer orders

SAP Cloud Integration helps you connect on-premises and cloud applications with other SAP and non-SAP on-premises and cloud applications. This service can handle messages in real-time scenarios that span different companies, organizations, or departments within an organization.

The SAP Integration Suite combines the integration capabilities of Process Integration, API Management, Integration Advisor, and Open Connectors into a cohesive, streamlined set of tools for enterprise integrations. To provide a complete integration experience, these services are not available separately, only as part of the Integration Suite service plan. For more information about the different service plans, seeIntegration packservice catalogue.

integration pack

With SAP Cloud Integration, you can package and publish integration content so that integration developers can use these packages in their integration scenarios.

As an integration developer, you can create integration packages for your specific domain or organization. You can also view various packages released by other integration developers and use them for your integration purposes. You can modify these packages as per your needs and load them through the web application.

integration flows

An integration flow lets you specify how a message is processed within a tenant.
You can use integration flows to specify specific integration patterns, such as mapping or routing.

A graphical editor allows you, as an integration developer, to model the message processing steps and specify in detail what happens to the message during processing.

security artifacts

Secure user credentials and parameters

User credentials and required parameters are created and stored in the Manage Security Material component in SAP CPI.

key shop

All keys, key pairs, and certificates for communicating with SAP CPI are stored in the SAP CPI Keystore.

(Video) SAP S/4HANA Cloud: Integrate your logistics end-to-end | Overview Demo

To enable a successful SSL handshake, the root certificates of connected systems must be added to the SAP CPI keystore.

SAP Emarsys Customer Engagement Value Mapping

Creates a value mapping artifact that acts as a bidirectional lookup table. Value mapping has the distinct advantage of providing bidirectional lookup capabilities that are commonly used in productive mapping scenarios.

Value mapping can be accessed from message mapping using the mapValue function.

When creating a custom integration, it's a good idea to define an external parameter to make setup easier. External parameters allow you to configure the IFlow without having to edit the IFlow.
Editing the IFlow is only necessary if you need to change the transformation and processing of the message, for example B. when adding and mapping a new custom field.

For more information on defining and configuring external parameters, refer to the SAP help documentation.

To configure IFlow, open the integration pack and select the "Configure" option from the drop-down menu.

  • Sender: Set receiver adapter for incoming messages.
  • Recipient: Set the sender adapter for outgoing messages.
    • If multiple sender adapters are configured, you can change the sender adapter from the drop-down list.
  • More: All external IFlow properties. The default view, Views. To view the externalized properties of a specific step in the message transformation, select the step from the drop-down list.

i flow:Business Partner Replication from SAP S4 HANA to SAP Emarsys Customer Engagement

This IFlow takes incoming messages from SAP S/4HANA and turns the incoming message into a well-formatted Emarsys contact API request.

Integrate SAP S/4HANA Cloud with SAP Emarsys Customer Engagement (3)

Step

Description

Station: S4OnPrem

Type: soap

SOAP sender is configured

  • Verzeichnis: /sap/bc/srt/scs/sap/businesspartnersuitebulkreplic_OnPrem
  • Processing Configuration: Robust
  • Permission: user role
  • User role: ESBMessaging.send
    The role must be assigned to the communication user used for authentication in the SAP BTP Cockpit.

content modifier

Set properties and headers

Message headers and properties are defined.

Exchange properties:

  • emarsysContactList - This is mandatory and defines the list of contacts in Emarsys. All contacts imported through this integration will be added to the defined contact list.
  • Security artifact: Required. Emarsys API user credentials must be created as a secure artifact for SAP CPI.
  • create_if_not_exists: Required. Values ​​are 1 or 0.
  • Contact Key ID: Required. Set the contact key field to be used as the unique contact identifier.
  • When using a custom field for Contact ID, the field must first be indexed.
  • removeEmpty: Optional. By default, empty values ​​are retained.
  • False: Empty values ​​are not removed. Empty values ​​overwrite existing data.
    True - Empty values ​​are removed and do not overwrite existing data.
  • administrative email; CPI administrator email is required if email notifications are enabled.
    This is required if error notifications are enabled.
  • enableReprocessing - Enables reprocessing of failed contact data.
    This required configuring and deploying both IFlows for reprocessing.
  • MailNotification - Email notifications can be enabled but require configuration of a CPI admin email and email template broadcast event in Emarsys.
    Both reprocessing ifflows need to be implemented.
  • inboundMessage: keep the inbound message. The received message is used in case of error, so that the same messages can be sent for reprocessing.

wonderful script

log incoming message

  • Writes the text of the received message.
  • Message logging must be enabled by setting the Enable logging exchange property to true.
  • Turn on message logging only when necessary. The message text is stored as an attachment in the message processing log (MPL).
  • To test the integration, it is recommended to record the "trace" level. Trace logging level can be turned on for 10 minutes and tracks all message processing including headers and message properties.

XSLT Mapping

Filter address information

  • Address information is filtered to include only the default address information.

message mapping

Emarsys contact mapping

  • SAP S/4HANA On-Prem message mapping for SAP Emarsys.
    • The message map contains most of the transformation logic for the message body.
  • Input Message Schema: Download the SOAMANAGER WSDL
    Use BusinessPartnerSUITEBulkReplicateRequest for business partner mapping.
    • IMPORTANT: The WSDL must not be changed manually. Download the latest SOAP web service configuration WSDL from SOAMANAGER.
  • Outgoing message schema
    Define the Emarsys message schema.
  • You can use Emarsys Field ID or String ID.
    • IMPORTANT: XML does not allow numeric element names in the XML schema.
      Emarsys contact API requires field id or field string id in the request payload. The option to use string id is relatively new (as of Feb 2022) and has caused some data replication issues (key id field not found and error responses).
      All fields are prefixed with tmp_, which is then removed in IFlow.

To change the message schema, for example when adding new custom fields, change the schema file in the IFlow resources. The message mapping schema is updated with the message schema and the additional field can be mapped.

Use graphical message mapping to fine-tune message transformation logic.
An Excel mapping file can be exported from Message Mapping.

Example of an Emarsys XML Schema with Emarsys Field ID:

When using the Emarsys Fields field ID, XML element names cannot be numeric. Add a prefix to all field names and remove the prefix later. The XML format does not allow definitions of elements such as <1>value</1>.

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema attributeFormDefault="not qualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="root">

<xs:tipocomplejo>

<xs:sequence>

<xs:element type="xs:string" name="contact_list_id"/>

<xs:element type="xs:string" name="key_id"/>

<xs:element name="Contacts" maxOccurs="unlimited" minOccurs="0">

<xs:tipocomplejo>

<xs:sequence>

<xs:element type="xs:string" name="tmp_1" maxOccurs="1" minOccurs="0"/>

<xs:element type="xs:string" name="tmp_2" maxOccurs="1" minOccurs="0"/>

<xs:element type="xs:string" name="tmp_3" maxOccurs="1" minOccurs="0"/>

</xs:stream>

</xs:tipocomplejo>

</xs:element>

</xs:stream>

</xs:tipocomplejo>

</xs:element>

</xs:schema>

Example of an Emarsys XML Schema with an Emarsys String Field ID:

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema attributeFormDefault="not qualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="root">

<xs:tipocomplejo>

<xs:sequence>

<xs:element type="xs:byte" name="key_id"/>

<xs:element name="Contacts" maxOccurs="unlimited" minOccurs="0">

<xs:tipocomplejo>

<xs:sequence>

<xs:element type="xs:string" name="Vorname" maxOccurs="1" minOccurs="0"/>

<xs:element type="xs:string" firstname="lastname" maxOccurs="1" minOccurs="0"/>

<xs:element type="xs:string" name="email" maxOccurs="1" minOccurs="0"/>

</xs:stream>

</xs:tipocomplejo>

</xs:element>

</xs:stream>

</xs:tipocomplejo>

</xs:element>

</xs:schema>

router

Validate PA

  • Branch 1: contactless/customer
    Default branch, message processing ends
  • Rama 2: valid function code
    Expression Type: XML
    condition: boolean(//contacts)
    If there is at least contact after message assignment for further processing. This avoids processing empty messages as not all trading partner short codes are processed.

router

remove empty

  • Branch 1: leave blank
    Default branching, keep values ​​empty.
  • Branch 2: remove empty
    Expression type: in XML
    Condition: ${property.removeEmpty} = 'yes'

If empty elements are removed, a delta update is sent to Emarsys without overwriting existing values.
If empty values ​​are left, existing values ​​will be overwritten.

XSLT Mapping

remove empty nodes

  • Remove empty nodes with no values.

This process step is only performed if the Delete empty branch option is enabled.

wonderful script

Create WSSE Header

  • The X-WSSE authentication header is generated.
  • Custom script function called: XWSSEHeader
  • The "securityArtifact" property is required to run this function.
    The securityArtifact property refers to the name of the security artifact that stores the Emarsys API user credentials

For more information on how to generate the WSSE header, see the Emarsys developer documentation.
https://dev.emarsys.com/docs/emarsys-api/ZG9jOjI0ODk5NzAx-autenticación

common divisor

Divisor-XML

The XML splitter splits the incoming message payload into smaller packets. The packet size can be configured in the General Splitter packet parameter.

The package can also be controlled by SAP S4HANA.

XML to JSON converter

Converts the XML message to a JSON message

wonderful script

remover tmp_

custom function called: replaceTmp

Replaces all tmp_ values ​​for field IDs to match Emarsys field IDs.

wonderful script

registration announcement

See Groovy script "Log incoming message"

content modifier

Remove Header URI

  • The SOAP sender stores the request URI path in the CamelHttpUri message header.
  • The HTTP Receiver adapter replaces the address defined in the adapter with the header value "CamelHttpUri" if a value is present.
  • The CamelHttpUri message header must be removed so as not to overwrite the recipient address.

Request answer

send contact

wonderful script

validate answer

  • Validate Emarsys' answer.
    Emarsys may respond with HTTP success status in the header but indicate an error in the response body.
  • custom function called: validResponse

router

  • Rama 1: HTTPCodeOK
    Expression type: in XML
  • Condition: ${property.responseStatus} = 'OK'
    Rama 2: HTTPCodeNotOK
    Default branch, stop processing.

subprocesso local

error handling

  • Error handling logs the error, decides whether messages should be saved for reprocessing, and whether to send an email notification.

subprocesso local

error handling

wonderful script

LogError

  • Logs and writes the message body as an attachment to the message processing log
  • custom function called: logHTTPError

subprocesso local

error handling

Router 1

  • No reprocessing - default path
  • Reprocessing: Reprocessing the message
    ${property.enableReprocessing} = 'true' e ${header.message_reprocessing} != 'true'
    enableReprocessing define este IFlow
  • message_reprocessing is defined in iflow for reprocessing

subprocesso local

error handling

content modifier

Reset message payload

  • Replace the body of the message with the body of the received message.
    ${property.incomingmessage}

subprocesso local

error handling

write data storage

Save the message to edit it again

  • The reprocessing message is written to the SAP CPI datastore, where IFlow collects it for reprocessing.
  • Datastore name: datastore name

subprocesso local

error handling

router

  • No email: default
  • Caminho: ${property.MailNotification} = 'true'
    Send an external event to Emarsys to trigger an email notification.

subprocesso local

error handling

wonderful script

definir host tmn

  • The script sets the tenant management host from the runtime URL. This URL is used as a personalization attribute in the email to link directly to SAP CPI Monitoring.
  • Tenant Management URL
    <tenant name>.<tenant location>.cfapps.us21.hana.ondemand.com
  • Tenant Runtime URL
    <tenant name>.<tenant location>-rt.cfapps.us21.hana.ondemand.com

subprocesso local

error handling

content modifier

define external event

  • The external event is defined in the content modifier because the request body is simple and generally does not require modification.

The following external event message text is sent to Emarsys.
External event information can be accessed in email personalization.

{

"email": "${property.adminEmail}",

"Data": {

"global": {

"adminEmail": "${propiedad.adminEmail}",

"timestamp": "${property.CamelCreatedTimestamp}",

"CPIHost": "${header.CPITmnHost}",

"CPIPath": "${header.CamelHttpUri}",

"Caught exception": "${property.CamelExceptionCaught}",

"expectionMessage": "${Exception.Message}",

"messageProcessingLogID": "${propiedad.SAP_MessageProcessingLogID}"

}

}

}

subprocesso local

error handling

content modifier
Remove Header URI

  • The CamelHttpUri is removed to avoid replacing the CamelHttpUri HTTP header on the receiver.

subprocesso local

error handling

wonderful script

Create WSSE Header

  • The script sets the WSSE authentication header

subprocesso local

error handling

Rezeptor HTTP

  • The error notification email is sent via a broadcast event. Streaming events do not require contacting Emarsys and are not tracked.
    ADDRESS:https://api.emarsys.net/api/v2/email/{Eventoid}/output
  • The Event ID: Defined in Emarsys by assigning the trigger email and selecting the broadcast event as the email trigger.

IFlow: Trading Partner Replication from SAP S4 HANA to SAP Emarsys Customer Engagement Data Reprocessing

This IFlow reprocesses failed messages from the Business Processing IFlow (IFlow:Business Partner Replication from SAP S4 HANA to SAPEmarsys Customer Engagement). Failed trading partners are stored in SAP CPI and reprocessed once a day. A time window outside of business hours is selected for reprocessing.

Most errors are failed authentication requests when Emarsys receives too many requests at the same time. Resending the same request should fix this issue.

Each failed message can be reprocessed up to two times before being saved for review.

Integrate SAP S/4HANA Cloud with SAP Emarsys Customer Engagement (4)

Step

Description

time the start

  • The startup timer schedules the IFlow to run and is configurable.
  • IFlow must be scheduled outside of business hours
  • IFlow should not run more than every minute.

data storage selection

Choose Contacts

  • Datastore name: Define the name of the datastore from which failed messages will be saved.
  • If the message is successfully processed, the entry is removed from the datastore.
  • Messages are processed individually

Dissident

split single message

  • Data Store Select is configured to collect only one datastore entry for each run.
  • The splitter is added to ensure that only one message is processed at a time.
  • Processing each datastore entry individually makes it easy to determine which message failed and which succeeded.
  • If there are multiple errors, the select operation can be modified to collect multiple messages. If multiple entries are selected, adjustments to the error process may be required.

Filter

  • The select operation adds additional elements to the retrieved message. The Filter step filters the selected message to match the original message
    Filterbedingung: //n0:BusinessPartnerSUITEBulkReplicateRequest

content modifier

  • Header: message_reprocessing is sent with the value "true" (fixed value).
  • This is used in business partner replication to avoid storing the message back in the datastore and creating duplicate entries.
  • Exchange property: inboundMessage sets the new inbound message to the second reprocessing IFlow in case the message fails again.

exception process

Reset message text

  • This step defines the new message body for the second IFlow reprocess

write data storage

Write data Check data storage

  • data store name
    Define datastore name for second IFlow for reprocessing

IFlow: SAP S4 HANA Trading Partner Replication for SAPEmarsys Customer Engagement Data Reprocessing 2

This IFlow is a copy of the first reprocess IFlow, except that the datastore write operation writes to a datastore for data validation, where the data is not encoded.

(Video) SAP Emarsys Customer Engagement demo

i flow:Replication of customer orders from SAP S4HANA to SAP Emarsys Customer Engagement

This IFlow takes incoming messages from SAP S/4HANA and transforms the incoming message into a well-formatted Emarsys Sales API request.

To avoid creating duplicate sales order data, sales order lines are only created when certain conditions are met.
Conditions when a sales order is considered completed may differ depending on how sales orders are processed in SAP S/4HANA.

Note that sales order imports are incremental and always add to existing sales data.
Upload your sales data:https://help.emarsys.com/hc/en-us/articles/213706429-Uploading-your-sales-data

It is recommended to control the release of sales data to Emarsys in SAP S/4HANA by defining certain conditions in SAP S/4HANA. Additional terms can be defined in SAP Cloud Integration, if required.

The described conditions are only an example and may differ for other defined systems and processes.

Data fields for installation conditions in SAP Cloud Integration can be at the order header and/or line item level.

  • The order is completed and shipped
  • The order will be canceled
  • Order is in progress
  • The item is complete and shipped.
  • The item has been canceled
  • The article is in progress

This is an example of how to define conditions to be implemented in SAP Cloud Integration.

The order is completed and shipped

The order will be canceled

Order is in progress

The item is complete and shipped.

The order is created

article is created

The order is created

the item has been removed

Request is ignored

The item has been canceled

The order is created

the item has been removed

The order is created

The element is created with negative values.

Request is ignored

The article is in progress

article is ignored

article is ignored

Request is ignored

Integrate SAP S/4HANA Cloud with SAP Emarsys Customer Engagement (5)

Step

Description

Station: S4OnPrem

Type: soap

  • SOAP sender is configured
  • Endereço: /SalesOrderBulkReplication_Out_OnPrem
  • Processing Configuration: Robust
  • Permission: user role
  • User role: ESBMessaging.send
    The role must be assigned to the communication user used for authentication in the SAP BTP Cockpit.

content modifier

Set properties and headers

  • Message headers and properties are defined.
  • Exchange properties:
  • File name: required. Defines the file name of the imported sales data
  • administrative email; CPI administrator email is required if email notifications are enabled.
  • MailNotification - Email notifications can be enabled but require configuration of a CPI admin email and email template broadcast event in Emarsys.

wonderful script

Register input payload

  • Writes the text of the received message.
  • Message logging must be enabled by setting the Enable logging exchange property to true.
  • Turn on message logging only when necessary. The body of the message is stored as an attachment in the message processing log (MPL) and the storage size of attachments is limited in SAP Cloud Integration.
  • To test the integration, it is recommended to record the "trace" level. The logging level can be turned on for 10 minutes and tracks all message processing, including headers and message properties.

common divisor

Divisor-XML

  • The XML splitter splits the incoming message payload into individual messages so that the message map can validate each sales order business document.
  • It is not necessary to process the sales order individually. Customer orders can be processed in batches.
  • In this example, the sales order is processed individually. Assigning commercial documents requires that the customer's order DB be edited individually; otherwise, the complex structure of the database can lead to erroneous message transformations.

message mapping

Emarsys contact mapping

  • SAP S/4HANA On-Prem message mapping for SAP Emarsys.
  • The message map contains most of the transformation logic for the message body.
  • Inbound Message Schema - The Inbound Message Schema is defined in the WSDL file downloaded from SOAMANAGER in SAP S/4HANA.
  • IMPORTANT: The WSDL must not be changed manually. Download the latest SOAP web service configuration WSDL from SOAMANAGER.
  • Output message schema:
    Define an XML Message Schema for Emarsys Sales Orders

To change the message schema, for example when adding new custom fields, change the schema file in the IFlow resources. The message mapping schema is updated with the message schema and the additional field can be mapped.

Use graphical message mapping to fine-tune message transformation logic.
An Excel mapping file can be exported from Message Mapping.

Emarsys Sales Data XML Schema Example

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema attributeFormDefault="not qualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- Documentation:https://help.emarsys.com/hc/en-us/articles/360003070654-Preparing-your-sales-data-file#required-fields-->

<xs:elementname="data">

<xs:tipocomplejo>

<xs:sequence>

<xs:item name="Sell Orders" minOccurs="0" maxOccurs="unlimited">

<xs:tipocomplejo>

<xs:sequence>

<xs:element name="order" minOccurs="0" maxOccurs="unlimited">

<xs:tipocomplejo>

<xs:sequence>

<xs:element type="xs:string" minOccurs="0" name="item"/>

<xs:element type="xs:string" minOccurs="0" name="preço"/>

<xs:element type="xs:string" minOccurs="0" name="order"/>

<xs:element type="xs:string" minOccurs="0" name="timestamp"/>

<xs:element type="xs:string" minOccurs="0" name="cliente"/>

<xs:element type="xs:string" minOccurs="0" name="email"/>

<xs:element type="xs:string" minOccurs="0" name="quantity"/>

</xs:stream>

</xs:tipocomplejo>

</xs:element>

</xs:stream>

</xs:tipocomplejo>

</xs:element>

</xs:stream>

</xs:tipocomplejo>

</xs:element>

</xs:schema>

XSLT Mapping

delete items

  • XSLT mapping removes sales order lines that should not be imported into Emarsys.
  • The conditions for importing the customer order are defined in the IFlow description above and implemented in an XSLT script.
  • All sales order items with item status "IN PROCESSING" are removed.
  • All sales order lines with general status "COMPLETED" and line status "CANCELLED" are removed.
  • All sales order lines with general status "CANCELLED" and line status "COMPLETED" are removed.
  • Other options are possible to fix this.

To bring together

  • The collect step gathers the shared items and combines them into a single message.

router

blank check

  • Branch 1: empty
    Default branch, message processing ends
  • Branch 2: not empty
    Expression Type: XML
    Condition: boolean(//sales order)
    If at least one sales order exists after assigning the message for further processing.

Filter

  • The Collect step filters only the relevant items.
  • The Gather step removed the parent nodes added in the previous steps
  • XPath Expression: //Order
  • Value type: notes

content modifier

add root

  • The content modifier adds a root element to the XML.
  • The root element is required in the XML for further processing and transformation.

XML to CSV Converter

  • Convert XML text to CSV
  • Path to source element in XSD: /salesorders/salesorder
  • Include field names as headers: checked
  • Include parent: disabled
  • Include Attribute Values: Disabled

wonderful script

outgoing load log

  • See nifty script "Register input payload"

content modifier

Emarsys Sales-API

  • Defines the necessary headers and properties.
  • Headers are predefined and should not be changed.
  • Merchant ID: Required. Merchant ID can be retrieved from Emarsys in Predict data feeds.
  • bearerToken - The bearer token that you store in a secure parameter in the CPI so that plain text is not displayed in the interface. The property refers to the name of the security parameter created in SAP CPI.

wonderful script

set permission

  • The UDF retrieves the bearer token stored in the security parameter and generates the authorization header.

Rezeptor HTTP

Send sales data

  • The HTTP receiver connects to the Emarsys Sales API.
  • All values ​​except Merchant ID and Wait Time are preconfigured.
  • Merchant ID and Timeout values ​​are managed as an external property.

router

  • Rama 1: HTTPCodeOK
  • Expression type: in XML
  • Condition: ${property.responseStatus} = 'OK'
  • Rama 2: HTTPCodeNotOK
    Default branch, stop processing.

wonderful script

logHTTPError

  • Logs and writes the message body as an attachment to the message processing log
  • custom function called: logHTTPError

subprocesso local

error handling

  • Standard error handling: Log the error and decide whether to send an email notification.
  • Error handling is the same for trade partner and sales order replication

IFlow error notification

SAP Cloud Integration provides an SMTP adapter to send emails directly from SAP Cloud Integration Email, but no email editor or other features to easily define and design an email. As we are already building an integration with SAPEmarsys Customer Engagement, the triggered email capabilities of the solution can be leveraged to send email notifications to a recipient.

For this specific use case, using broadcast events to trigger an email may be more suitable than external events, as emails with broadcast events do not require the contact to be in your contact database and the Email transmissions are not tracked by transmission events. Broadcast emails are still considered external event emails for billing purposes.
Once created and activated, you can allow error notifications to be sent from different IFlows using the same process.

In this example we define the recipient who should receive the error message in IFlow. Additional attributes are defined and passed in the request body, which can then be used for email personalization in Emarsys. Changes to the email can be made without changing the IFlow.

For more information, see the Emarsys email-enabled documentation.

(Video) SAP Emarsys: Product Recommendations

Triggered Email – End User Guide:https://help.emarsys.com/hc/en-us/articles/360016376278-End-user-guides-Triggered-Email-End-user-guide

Integrate SAP S/4HANA Cloud with SAP Emarsys Customer Engagement (6)

SAP CPI Configuration

  • Enable email notification by setting the MailNotification exchange property to true.
    • We added this to allow the CPI manager to decide whether or not to enable error notifications.
  • Add an email address for the SAP CPI administrator.
    • In our example, we set the email notification recipient in IFlow as an external property.
      The recipient can also be passed from the incoming request and set dynamically in the CPI.
  • In the HTTP receiver channel for the email notification, add the streaming event ID generated by Emarsys.

Emarsys Configuration

  • Create new email enabled
  • Select Broadcast Event as the trigger.
    A broadcast event ID is provided.
  • Define an email template.
  • Enable triggered email flow

Example of a broadcast event defined in SAP CPI.

{

"email": "${property.adminEmail}",

"Data": {

"global": {

"adminEmail": "${propiedad.adminEmail}",

"timestamp": "${property.CamelCreatedTimestamp}",

"CPIHost": "${header.CPITmnHost}",

"CPIPath": "${header.CamelHttpUri}",

"Caught exception": "${property.CamelExceptionCaught}",

"expectionMessage": "${Exception.Message}",

"messageProcessingLogID": "${propiedad.SAP_MessageProcessingLogID}"

}

}

}

Step

Description


wonderful script

Registry Error

  • Stores the message payload as an attachment in the message processing log.

Router 1

  • Branch 1: no processing (default)
  • Industry 2: Reprocessing
    ${property.enableReprocessing} = 'true' e ${header.message_reprocessing} != 'true'

Message reprocessing branch

  • The message body is reset as received and stored in the SAP Cloud Integration data store.
  • The datastore write operation is defined to store the failed message.
    Entry visibility must be set to "Global".

router

  • Branch 1: email, send email notification
  • Branch 2: no email, no email notification
  • Conditional expression: ${property.MailNotification} = 'true'


wonderful script

Definir host tmn

  • The error message includes a link to the CPI Tenant Monitoring overview.
  • In this step, the tenant management node is defined.
  • Function called: defineTmnUrl

content modifier

define external event

  • The body of the broadcast event request is defined.
  • Available customization attributes:
  • {{evento.adminEmail}}
    CPI admin email defined in IFlow configuration
  • {{event.timestamp}}
    Error timestamp
  • {{event.CPIHost}}
  • SAP CPI Tenant Management Host
  • {{event.CPIPath}}
    SAP CPI endpoint path
  • {{event.catchException}}
  • Caught exception message
  • {{evento.expectionMessage}}
  • exception message
  • {{event.messageProcessingLogID}}
    SAP CPI MPL ID, used to look up the error message in the message processing log
  • Required parameters for email notification should be defined based on relevant use cases.

content modifier

Remove Header URI

  • Remove CamelHttpUri header to avoid overwriting target host URL
  • Delete: $name=CamelHttpUri

wonderful script
Create WSSE Header

  • Create the authentication header
  • Function call: XWSSEHeader

request-response

send error message


SAP Emarsys Customer Engagement Setup

api users

Create an API user in SAPEmarsys Customer Engagement and create a security artifact with the Emarsys API user credentials in SAP Cloud Integration. The security artifact can be accessed via IFlow.

In Emarsys, add the necessary permissions for the external contacts and events API to the API user.

Sales Data API

The Sales Data API endpoint and token can be obtained from Emarsys.

Open Forecast Data Sources and go to Manage Your Sales Data to find the Sales Data API upload details.

E-mail triggered for SAP Cloud Integration error notifications

A triggered email is created with a triggering broadcast event.

For more information on triggered emails, see the Emarsys help documentation.

Step Description
Email enabled by Emarsys Channels > Enabled Emails > Create Message Flow
email settings

Complete the email settings and select "Broadcast event" in the activation settings.

Note the broadcast event ID

Integrate SAP S/4HANA Cloud with SAP Emarsys Customer Engagement (7)

content creation Set the email basics and set the error message email to be sent.

Videos

1. SAP S/4HANA Utilities Demo Series | Customer Engagement
(SAP Industries)
2. SAP Customer Engagement Intelligence powered by SAP HANA
(Performance Analytics Corporate)
3. SAP S/4HANA Cloud: Customer Management | Overview Demo
(SAP)
4. What is SAP S/4HANA Cloud? Overview Demo
(SAP)
5. SAP S/4HANA Cloud Onboarding
(SAP Products & Services)
6. How to Set Up Application Monitoring SAP S/4HANA Cloud, SAP IBP and SAP Marketing Cloud
(Services and Support from SAP)
Top Articles
Latest Posts
Article information

Author: Duane Harber

Last Updated: 04/27/2023

Views: 5641

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Duane Harber

Birthday: 1999-10-17

Address: Apt. 404 9899 Magnolia Roads, Port Royceville, ID 78186

Phone: +186911129794335

Job: Human Hospitality Planner

Hobby: Listening to music, Orienteering, Knapping, Dance, Mountain biking, Fishing, Pottery

Introduction: My name is Duane Harber, I am a modern, clever, handsome, fair, agreeable, inexpensive, beautiful person who loves writing and wants to share my knowledge and understanding with you.