3

S/4Hana Cloud Event Trigger an Iflow in Sap Integr... - SAP Community

 2 months ago
source link: https://community.sap.com/t5/technology-blogs-by-sap/s-4hana-cloud-event-trigger-an-iflow-in-sap-integration-suite/ba-p/13647432
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

In SAP S/4Hana Cloud, when event for some business object happened like sales order created, some additional logic need to be triggered, for example additional information should be put for this sales order.  We can utilized SAP Event Mesh and SAP Integration Suite to realized such kinds of requirements .

The following is solution example .

SolutionOrderCpi.drawio.png

Prerequisites:

  • SAP S/4Hana Cloud has gone alive or in implementation.
  • Have subscribed SAP Event Mesh in Sap Business Application Platform
    and finished the initial settings. You have the Event Mesh instance Service Key which will be used in step 1 .
    image.png
  • Have subscribed SAP Integration Suite in Sap Business Application Platform and finished the initial settings .

    Realizing Steps:

    Step 1:  Create communication user  and create  communication arrangement for scenario SAP_COM_0092 in SAP S/4Hana Cloud .

    image-1.png
    image-2.png
    image-3.png
    image-4.png
    image-5.png
    image-6.png

    Step 2:  Create communication arrangement for sales order in SAP S/4Hana Cloud .

    image-3.png
    image-7.png

    Step 3:  Bind sales order created topic to event channel in SAP S/4Hana Cloud .

    image-8.png
    image-9.png
    image-10.png
    image-11.png

    Step 4:  Create event queue for sales order in SAP Event Mesh Subscription in SAP Business Technology Platform.

    image-12.png
    image-13.png
    image-14.png
    image-15.png
    image-16.png
    Now the event queue can receive events of sales order created from S/4Hana Cloud .

    Step 5:  Create and Deploy Iflow in SAP Integration Suite .

    Create Oauth2 Client Credential base on Event Mesh service key and Basic User account for Sales Order API Inbound user in SAP Integration Suite.
    image-17.png
    image-18.png
    image-19.png
    image-20.png
    image-21.png
    Create and Deploy Iflow.
    image-22.png
    image-23.png
    image-24.png
    image-25.png
    image-26.png
 import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.JsonSlurper;
def Message processData(Message message) {
    def body = message.getBody(java.lang.String)
    
    def jsonObject = new JsonSlurper().parseText(body)
    def salesOrder = jsonObject.data.SalesOrder
    message.setHeader('salesOrder', salesOrder)
    
    def messageLog = messageLogFactory.getMessageLog(message)
    if (messageLog != null) {
        messageLog.addAttachmentAsString('event', body, 'application/json')
    }
    return message
}
image-27.png
image-28.png
image-29.png
image-30.png
image-31.png
image-32.png
image-34.png
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
    def body = message.getBody(java.lang.String)
    def messageLog = messageLogFactory.getMessageLog(message)
    if (messageLog != null) {
        messageLog.addAttachmentAsString('SalesOrder', body, 'application/xml')
    }
    return message
}
image-33.png

Step 6: Test - Create Sales Order in S/4Hana Cloud and Check result in SAP Integration Suite .

image-35.png
image-36.png
image-37.png
image-38.png

The End

Thanks for your time!

Jacky Liu


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK