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.
cancel
Showing results for 
Search instead for 
Did you mean: 
In a world full of promotions in every shape and size, consistency is the key to a seamless buying experience for the consumer. With SAP Omnichannel Promotion Pricing, SAP offers exactly that by ensuring consistent pricing across sales channel applications. You can define any number of promotional rules using a variety of triggers and rewards based on which the Calculation service determines the effective sales prices in the respective customer context.

In this blog, we will discuss how you can facilitate the fetching of merchandise hierarchy nodes, which are collections of items with similar properties, from SAP S/4HANA to the Calculation service and their validation.

Let’s begin with setting up the cloud integration package required to facilitate the communication between SAP S/4HANA and SAP Omnichannel Promotion Pricing.

Prerequisites

Procedure

  • Log in to SAP Cloud Integration.

  • In the navigation panel, choose Design to access your integration workspace.

  • Choose Create to build an integration package and Save it.




After completing these steps, you are now able to successfully use the new cloud integration package.

Setting Up the Integration Flows


I. Integration Flow for Fetching Merchandise Hierarchy Nodes

The ‘Fetch Merchandise Hierarchy Nodes from SAP S4HANA’ integration flow can be used to retrieve data from a back-end system. Let’s take a look at the procedure to configure the integration flow.

  • Select the new integration package that you have just created and choose Artifacts.

  • Choose Add > Integration Flow.





  • Enter a name for the integration flow and choose OK.





  • Save your configuration.

  • Select the integration flow that you just created and choose Edit.

  • To define the sender channel and adapter, select the Sender tab and drag the arrow icon to Start.





  • In the dialog box that pops up, select the adapter type HTTPS.

  • In the properties, choose Connection and enter the address /merchandiseNodes.

  • To upload the source and target files in XSD format, click anywhere on the screen and select Integration Flow > Resources > Schema > XSD > Browse. Choose Add once you have uploaded the files.



Note: Create two .xsd files on your local computer using the following code snippets and upload them to the integration flow.


Source File: oppsui_request.xsd



<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="OPPSUiMerchandiseHierarchyRequest">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:byte" name="HierarchyId"/>
<xs:element type="xs:string" name="HierarchyName" minOccurs="0"/>
<xs:element type="xs:string" name="SearchValue" minOccurs="0"/>
<xs:element type="xs:string" name="QualifierId" minOccurs="0"/>
<xs:element type="xs:string" name="QualifierName" minOccurs="0"/>
<xs:element type="xs:string" name="sap-language" minOccurs="0"/>
<xs:element type="xs:string" name="SkipValue" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Target File: s4_request.xsd



<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Z_MERCHANDISE_HIERARCHY">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:byte" name="HIERARCHY_ID" minOccurs="0"/>
<xs:element type="xs:string" name="HIERARCHY_NAME" minOccurs="0"/>
<xs:element type="xs:string" name="SEARCH_VALUE" minOccurs="0"/>
<xs:element type="xs:string" name="QUALIFIER_ID" minOccurs="0"/>
<xs:element type="xs:string" name="QUALIFIER_NAME" minOccurs="0"/>
<xs:element type="xs:string" name="DESCR_LANG" minOccurs="0"/>
<xs:element type="xs:string" name="HIERACHY_MAX" minOccurs="0"/>
<xs:element type="xs:string" name="SKIP_VALUE" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>


  • Note:

    • While retrieving merchandise hierarchy nodes from your backend system, you must ensure the element “SKIP_VALUE” is included in both the request and target XSDs. This is to facilitate the correct pagination of your master data records. If you do not already have the element in your schema, you must delete the existing schema and upload a revised one.

    • You are free to use any element name in the target XSD. While setting up the RFC, make sure that the RFC name matches the target element name and the parameters with the element type names.



  • In the menu bar on the top of the screen, choose Mapping > Message Mapping.

  • Select the new tile and enter a name for it on the General tab.





  • Choose the tile again and select Create to provide the message mapping name. Enter the name and choose Create.





  • In the window that opens, choose the source and target files xsd and s4_request.xsd that you have created previously.

  • Now, do the mapping by connecting the source to the corresponding target.





  • For the HIERARCHY_MAX field, drag and drop it to the Mapping Expression In the Functions search bar, search and select constant and enter a maximum value up to 90.





  • Choose OK.

  • Add a Request Reply by choosing Call > External Call > Request Reply and name it ‘Get Merchandise Category Hierarchies’.





  • Connect the message mapping and request reply. Now, draw an RFC connection between the request reply and receiver by selecting the Connector icon and choosing the adapter type RFC.





  • In the property panel of the RFC, choose Connection and enter the destination name.



Note: The destination name should be an exact match of that entered in CPI space.





  • Go back to SAP Cloud Integration. To remove the root node, choose Mapping  > XSLT mapping and name it before connecting it to request reply. Then, choose Create .






  • Now, copy the following code snippet and choose OK.


   <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- identity template -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>

<!-- template for the document element -->
<xsl:template match="/*">
<xsl:apply-templates select="node()" />
</xsl:template>

</xsl:stylesheet>


  • Create a response mapping with the name S4HANA to Promo UI.

  • Upload the following XSDs as shown earlier and add the source and target messages.


Source XSD: s4_response.xsd



<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Z_HIERARCHY_RETURN">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="QUAL_ID"/>
<xs:element type="xs:string" name="QUAL_NAME"/>
<xs:element type="xs:string" name="HIER_ID"/>
<xs:element type="xs:string" name="HIER_NAME"/>
<xs:element type="xs:string" name="HIER_ID_SUB"/>
<xs:element type="xs:string" name="HIER_NAME_SUB"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Note: You are free to use any element name in the source XSDs. Make sure that the RFC response name matches the target element name and the parameters with the element type names.


Target XSD: oppsui_response.xsd



<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="MerchandiseHierarchies">
<xs:complexType>
<xs:sequence>
<xs:element name="OPPSUiMerchandiseHierarchyResponse" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="QUALID" minOccurs="0"/>
<xs:element type="xs:string" name="QUALNAME" minOccurs="0"/>
<xs:element type="xs:string" name="HIERID" minOccurs="0"/>
<xs:element type="xs:string" name="HIERNAME" minOccurs="0"/>
<xs:element type="xs:string" name="HIERID_SUB" minOccurs="0"/>
<xs:element type="xs:string" name="HIERNAME_SUB" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


  • Create the mapping and choose OK.





  • Save your configuration and choose Deploy.


The final integration flow should look like this:


 

II. Integration Flow for Validating Merchandise Hierarchy Nodes

The ‘Validate Merchandise Hierarchy Nodes in SAP S4HANA’ integration flow can be used to verify whether the merchandise hierarchy nodes entered by the user exist in the back-end system.

  • Select the integration package and choose Artifacts > Edit.

  • Choose Add > Integration Flow.





  • Enter a name for the integration flow and choose OK.

  • Save your configuration.

  • Select the integration flow and choose Edit.

  • To define the sender channel and adapter, select the Sender tab and drag the arrow icon to Start.





  • In the dialog box that pops up, select the adapter type HTTPS.

  • In the properties, choose Connection and enter the address /validateMerchandiseNodes.

  • To add a splitter, choose Message Routing > Splitter > Iterating Splitter.





  • On the General tab, name the splitter as ‘Splitting each merchandise hierarchy node’.

  • In the Processing tab, enter the following details:






























Field



Value


Expression Type XPath
XPath Expression /OPPSUIMerchandiseHierarchyValidationRequest/merchandiseHierarchy
Parallel Processing Yes
Number of Concurrent Processes 50
Timeout (in s) 300


  • Upload the source and target XSDs using the following code snippets:


Source XSD: oppsui_request.xsd



  <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="merchandiseHierarchy">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:byte" name="HierarchyId" minOccurs="0"/>
<xs:element type="xs:string" name="HierarchyName" minOccurs="0"/>
<xs:element type="xs:string" name="SearchValue" minOccurs="0"/>
<xs:element type="xs:string" name="QualifierId" minOccurs="0"/>
<xs:element type="xs:string" name="QualifierName" minOccurs="0"/>
<xs:element type="xs:string" name="sap-language" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Target XSD: s4_request.xsd



<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Z_MERCHANDISE_HIERARCHY">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:byte" name="HIERARCHY_ID" minOccurs="0"/>
<xs:element type="xs:string" name="HIERARCHY_NAME" minOccurs="0"/>
<xs:element type="xs:string" name="SEARCH_VALUE" minOccurs="0" />
<xs:element type="xs:string" name="QUALIFIER_ID" minOccurs="0"/>
<xs:element type="xs:string" name="QUALIFIER_NAME" minOccurs="0"/>
<xs:element type="xs:string" name="DESCR_LANG" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Note: You are free to use any element name in the target XSD. While setting up the RFC, make sure that its name matches the target element name and the parameters with the element type names.




  • In the menu bar, choose Mapping > Message Mapping and name the tile ‘Promo UI to S/4HANA’.

  • Choose Create  to provide the message mapping name. Enter the name and choose Create.





  • In the window that opens, choose the source and target messages xsd and s4_request.xsd respectively.

  • Now, do the mapping by connecting the source to its corresponding target and select OK.





  • Choose Message Transformers > Content Modifier to save merchandise hierarchy ID and qualifier ID.

  • Click on the content modifier and navigate to Exchange Property > Add. Then, enter the details mentioned in the following table:












































Name Field Value
HierarchyId Action Create
Type XPath
Data Type Java.lang.String
Value //HIERARCHY_ID
QualifierId Action Create
Type XPath
Data Type Java.lang.String
Value //QUALIFIER_ID




  • Add a Request Reply by choosing Call > External Call > Request Reply and name it ‘Get Merchandise Category Hierarchies’.

  • Connect the message mapping and request reply and draw an RFC connection between the request reply and receiver.

  • In the property panel of the RFC, choose Connection and enter the destination name.


Note: The destination name should be an exact match of that entered in CPI space.




  • To remove the root node, add XSLT mapping and name it before connecting it to request reply. Then, select Create  and enter the following code snippet:





<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- identity template -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>

<!-- template for the document element -->
<xsl:template match="/*">
<xsl:apply-templates select="node()" />
</xsl:template>


  • Create a response mapping with the name ‘S4HANA to Promo UI’.

  • Upload the following XSDs as shown earlier and add the source and target messages.


Source XSD: s4_response.xsd



<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Z_HIERARCHY_RETURN">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="QUAL_ID"/>
<xs:element type="xs:string" name="QUAL_NAME"/>
<xs:element type="xs:string" name="HIER_ID"/>
<xs:element type="xs:string" name="HIER_NAME"/>
<xs:element type="xs:string" name="HIER_ID_SUB"/>
<xs:element type="xs:string" name="HIER_NAME_SUB"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Note: You are free to use any element name in the source XSDs. Make sure that the RFC response name matches the target element name and the parameters with the element type names.


Target XSD: oppsui_response.xsd



<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="MerchandiseHierarchies">
<xs:complexType>
<xs:sequence>
<xs:element name="OPPSUIMerchandiseHierarchyValidationResponse" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="QUALID" minOccurs="0"/>
<xs:element type="xs:string" name="QUALNAME" minOccurs="0"/>
<xs:element type="xs:string" name="HIERID" minOccurs="0"/>
<xs:element type="xs:string" name="HIERNAME" minOccurs="0"/>
<xs:element type="xs:string" name="HIERID_SUB" minOccurs="0"/>
<xs:element type="xs:string" name="HIERNAME_SUB" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


  • Create the mapping by connecting the corresponding source and target messages. Choose OK.





  • Add an XSLT Mapping to check whether there is a validation response.





  • Choose Create and add the following code snippet. Select OK.


<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:param name ="QualifierId" />
<xsl:param name ="HierarchyId" />
<xsl:param name ="isPresent" />
<xsl:template match="/MerchandiseHierarchies">
<MerchandiseHierarchies>
<xsl:if test="OPPSUIMerchandiseHierarchyValidationResponse">
<OPPSUIMerchandiseHierarchyValidationResponse>
<qualifierId><xsl:value-of select="$QualifierId"/></qualifierId>
<hierarchyId><xsl:value-of select="$HierarchyId"/></hierarchyId>
<isPresent>true</isPresent>
</OPPSUIMerchandiseHierarchyValidationResponse>
</xsl:if>
<xsl:if test="not(OPPSUIMerchandiseHierarchyValidationResponse)">
<OPPSUIMerchandiseHierarchyValidationResponse>
<qualifierId><xsl:value-of select="$QualifierId"/></qualifierId>
<hierarchyId><xsl:value-of select="$HierarchyId"/></hierarchyId>
<isPresent>false</isPresent>
</OPPSUIMerchandiseHierarchyValidationResponse>
</xsl:if>
</MerchandiseHierarchies>

</xsl:template>
</xsl:stylesheet>


  • To add a gather, choose Message Routing > Gather.

  • Choose the gather and enter the aggregation strategy with the following details:

    • Aggregation Algorithm: Combine at XPath

    • Combine from source (XPath): //OPPSUIMerchandiseHierarchyValidationResponse



  • To remove unnecessary root nodes, add XSLT mapping.





  • Choose Create and add the following code snippet. Select OK.


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- identity template -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>

<!-- template for the document element -->
<xsl:template match="/*">
<MerchandiseHierarchies>
<xsl:apply-templates select="node()" />
</MerchandiseHierarchies>
</xsl:template>

</xsl:stylesheet>


  • Save your configuration and choose Deploy.


The final integration flow should look like this:



Using Master Data for Fetch and Validation of Merchandise Hierarchy Nodes


To successfully use merchandise hierarchy nodes in a promotional rule, a user of SAP Omnichannel Promotion Pricing must set up a remote function call (RFC) to provide the required master data. When configured properly, it can be used to fetch and validate the merchandise hierarchy nodes.

  1. Fetch – The fetching of merchandise hierarchy nodes is done using either the search value or the qualifier identifier, or both. While hierarchy ID and hierarchy name are searched as ‘contains’, only an exact match will be done for the qualifier ID. Together with the description language, the number of entries fetched are either the maximum value defined under Hierarchy Max or lesser.

  2. Validate – The validation of merchandise hierarchy nodes in the back-end system is done as an ‘exact match’ using the hierarchy identifier and qualifier identifier. The RFC sends a response only if the entries are correct.


You must include the following entry and response parameters in the RFC to get the appropriate result which is in the form of a table:











Entry Parameter Response Parameter


Search Value

Qualifier Identifier

Hierarchy Identifier

Hierarchy Name

Description Language

Hierarchy Max


Qualifier Identifier

Qualifier Name

Hierarchy Identifier

Hierarchy Name

Hierarchy Identifier Subnode

Hierarchy Name Subnode

Note: While the hierarchy qualifier name helps you understand which hierarchy the node belongs to, the hierarchy identifier subnode and hierarchy name subnode are filled only if the merchandise hierarchy node has a dependent assigned to it.


That’s All Folks!

On successful completion of these steps, you are now able to fetch and validate merchandise hierarchy nodes in a promotional rule from SAP S/4HANA to SAP Omnichannel Promotion Pricing.

 


1 Comment