Blog > Events with CPI, Enterprise Messaging and Node.js app part 1 – S/4HANA Enterprise Event Enablement

Events with CPI, Enterprise Messaging and Node.js app part 1 – S/4HANA Enterprise Event Enablement

Andrzej Halicki SAP Integration Consultant
icon__calendar 2020-05-20

In this article you will learn:

  • How to configure Enterprise Event Enablement in S/4HANA system
  • How to connect to Enterprise Messaging service from S/4HANA

 

What’s the scenario?

We want to notify our Node.js app in Cloud Platform that Sales Order was created. In order to achieve this we will enable Enterprise Events in our S4 and configure it this way that an event will be sent to Enterprise Messaging service after SO creation. This will be covered in this blog. Later we will create a queue, topic and webhook subscription in EM service to CPI. CPI will collect SO data via OData call and pass it to Node.js app. This part will be covered in part 2 of this blog. Last but not least, we will consume CPI message in our app and enable direct consumption from Enterprise Mesaging (part 3).

Let’s take a look at more friendly representation:

 

S4Events1

In the third part we will cover the below scenario:

S4Events2

Let’s move to the basics and enable and configure our events.

Enterprise events enablement

Actually this topic was quite well covered in other blogs and articles, but despite that I still couldn’t make it work (finally I did of course). I will refer to other materials and will not duplicate them here – you will have to read them and follow all the instructions there. I will guide you through all other things that were not mentioned.

So first of all – take a look at this great blog: https://blogs.sap.com/2019/09/16/sap-enterprise-messaging-for-s4hana-on-premises/.

Step 2

In my case SSL Standard did not work when I uploaded certificates via STRUST. Try using an Anonymous profile.

Step 4
A.Halicki_enterprise_messaging

 

Enterprise_event_enablement_step4

 

Step 5

 

Enterprise_event_enablement_step5

 

Step 6 (Enterprise Messaging)

My queue:

Enterprise_messaging_queue

My Topic:

Enterprise_messaging_topic_name

 

As you can see, I explicitly stated topic pattern but you can use “S42/*” as stated in the article.

 

Events for change document configuration (swec and swetypv)

It’s an old and well known transaction but it’s worth mentioning – S/4HANA events are based on this concept. So lets move to tcode SWEC and enable events for sales order creation:

 

Events_for_change_document

 

VERKBELEG and BUS2032 will be our sales order, event CREATED and on change. If you want to add field restrictions – feel free to do so.

Now, let’s move to tcode SWETYPV and create a new entry:

 

New_entry_creation

 

Testing

Let’s create a Sales Order in VA01. After hitting save you should see a message in your queue:

 

Sales_order_creation_VA01

 

It’s not there? Ha! This happend to me as well (one can go mad trying to figure out why). Take a look at this topic in answers.sap:

First, follow instructions by Tobias:

 

sap_answer_tobias

 

It worked for me but worked the unexpected way. At first, I wanted to create a scenario with Sales Order change event but it didn?t want to work. I went into a debug mode and found out table BEH_C_SUBSCRIPTN. Values are as presented:

 

BEH_C_SUBSCRIPTN_table

 

114 is Sales Order and 21 is CREATED event. I tried to find out how to maintain this table and it occurred it is possible as of version 1909 from Fiori app. I haven’t found any other way to change it, if you know one let me know in the comments.

The best answer by Tobias gives a solution for the problem (at the bottom of the thread). Just remember to create user SAP_WFRT with proper authorizations before configuration in SWU3.

It may happen that you will get such message in SWUE:

 

SWUE_message

 

Although my user SAP_WFRT had all authorizations it still did not work. You can try doing a workaround and assign destination explicitly in SWETYPV:

 

event_change_view

 

This should solve all problems and now you should be able to see message in your Enterprise Messaging service.

 

Summary

In this article, I (and other guys from the SAP Internet) showed you how to configure Enterprise Event Enablement in S/4HANA, how to configure events for change documents and how to troubleshoot potential errors. In part 2 we will create webhook to CPI, consume OData and move the message to Node.js app. See you there!

 

Andrzej Halicki SAP Integration Consultant
Andrzej Halicki is an SAP integration consultant and developer. He has strong experience in ABAP development across local and international projects. Andrzej works with the latest solutions like ABAP for HANA and Cloud Platform Integration. Author of many technical articles that are available online in the SAP Community and Int4 website.

Contact us

If for any reason, the thought of reaching out to us has crossed your mind, then by all means do not hesitate to get in touch with us, as we are more than happy to put to rest all of your concerns.