Knock the SCP EMS door from Backend (OP)!! – Event Messaging Service in SCP
Hello Everyone, A very Happy Year Near to all the Community members. This is my first blog of 2020 and was on my list for quite sometime as i was struggling to set this up :)…
As we know, Business Workflows are the heart of SAP Applications and with SCP Workflows coming into existence, this Heart has grown bigger and better… Now, we can have workflows responding to actions accross systems and not just applications within a system… At the sametime we can’t ignore the Event Messaging Service (EMS), which keeps this heart beating… isn’t It??
When i started exploring the EM Service i found many good blogs like the one here by Pradeep Panda , which explains how to set up Event Messaging services with SAP S/4HANA Cloud with screen prints. But i wanted to set it up with OnPremise events , so i looked further and got SAP help link here and a wonderful blog by Paolo Sfilio which explains all the steps required to setup the EM Service to register events from On-Prem backend system.
I followed them and struggeled a bit as well as i missed the screens, to refer to, while follwing the steps. Finally, i was able to do it successfully.
Now, i thought, why not share the process with screen prints to help people set it up even faster and help them spend more time in building super cool event driven apps then in struggling with the setup.
So, lets revisit the setup process, this time with screens 🙂 …
Before, we start with On-Premise configuration we need to have following prerequisites completed:
- SCP CF Trial Account
- Subscription to Even Messaging service in SCP and Instance created for same and service key generated. (We will need, MQTT uri, ClientID, Client Secrent and token endpoint, from the generated service key, for backend component configuration)
- SAP S/4HANA Backend system
Once, we have all the above mentioned Pre-requisite steps done, we are all set up the backend system.
Configuring Enterprise Event Enablement
Configuring the Enterprise Event in Backend On-Premise system we need to perform the following configuration steps:
User Roles and Authorization – Create a role for event administrators with below mentioned role templates
Role template for Enterprise Event Enablement administrator.
With this template you can perform all admin tasks such as, checking logs, CCMS, OAuth client and RFC creation.
Role template for Enterprise Event Enablement business administrator.
With this template you can maintain the event topics for the channel.
Role template for Enterprise Event Enablement metadata administrator.
With this template you check metadata of the service, BROWSER_SRV.
- Create a new role tcode PFCG
- Chose above mentioned Templates, under Authorizatio tab, one by one and generate.
- Assign role to the required users
Upload the event messaging service certificate
To do so follow the below mentioned steps:
- Copy the Token endpoint url from the Event messaging instance service key
- Download the certificates from the URL
- Upload certificates in STRUST tcode in backed under standard and Anonymous PSE
Create an RFC Destination
- Copy the URI from the service key for the protocol mqtt311ws
- Use the URI without WSS:// to create RFC destination
- Under ‘Logon & Security’ tab, switch SSL to active and select the PSE under which EMS Certificates were loaded.
- Do the Connection test and if you get the popup to enter credentials, that means its fine, despite it being not accepting the credentials and resulting in 401 unauthorized error.
Manage OAuth 2.0 Account Client Setup
To access SCP Enterprise Messaging OAuth 2.0 protected service in S/4HANA backend system , we need to OAuth 2.0 Account Client Setup by following the following steps:
- Copy OAuth client id, client secret and token endpoint of the mqtt311ws protocol from the enterprise messaging service instance service key.
- Perform the OAuth client setup at the IMG path shown below
- Click on create OAuth client and select details as shown below and enter any name and Client ID as copied from service key
- Enter the client secret, token endpoint, Authorization endpoint (same as token endpoint with token replaced with authorize at the end) and other details as shown below
Manage Channel and Parameters from the IMG path shown below
- Navigate to ‘Manage Channel and Parameter’ at the IMG path shown below
- Create a new channel as shown below with protocol MQTT_311_WS, RFC destination as created earlier, Topic space (system ID of the backend system preferably) and description as needed
- Maintain parameters for channel as shown below
- Perform the connection test for the channel and it should be successful in case all is done properly
Activate Event Discovery Service
To discover events from SAP Enterprise Messaging in SAP Cloud Platform, activate the OData service, BROWSER_SRV. Add service BROWSER_SRV in SAP Gateway tcode /IWFND/MAINT_SERVICE
Maintain Event Topics
Before we mantain the Topics (Business Objects) for which we want to register the events, navigate to ‘Manage Service’ at the below IMG path in SPRO.
- We can see the service which generates the events under “Manage Service”
- Now we need to register topics, for which we want to register events, by navigating to “Manage Event Topics” and Selecting the channel we created in earlier steps
- Create New entry and select the required Topic filters
- Let’s say we want to capture all the events related to Sales Order, so we can select topic as shown below.
With this we are done with the Backend configuration have matained the Sales Order events to be registered in SCP EM Service.
Creating queue In SCP to register OP events
- Now we need to go to the Event messaging service in SCP account and open the EMS dashboard
- Under the Queues, created a queue (any name). Initially the Number of Messages will be blank.
- Then go to Queue Subscription and create a new subscription for the created queue and in topic space enter the value as is maintained in configuration of Channel and parameters like <topic space>/*.
With this we are done with the entire setup and now is the time to test. 🙂
- Before test let’s see how the Queue Overview looks like.As we can see there is one queue and 4 messages already.
- Now let’s make a change in the SO in the backend and see what happens.
- Let’s change the delivery date and save the Sales Order
- Now let’s go and monitor the queue in SCP and as we can see below the Number of messages is now increased by one and is 5 now.
So, our testing is successful and On-Prem events are ready to be consumed in event driven applications now!!
I would ask my friend Mahesh Kumar Palavalli , the fiori Element baba :), if he could help and create one simple sample app to show how these events can be consumed in applications , that would realy be wonderful 🙂
Keep Learning , Keep sharing 🙂
Very Informative step by step post Vijay Sharma , I saw this at TechEd and seeing it now here I’ve got a lot to catch up on
I know you will catch up quickly Mahesh Kumar Palavalli 🙂
We are on the landscape of S4 Hana 1809 on premise version, we have setup all the instruction given in this blog but we could not see any messages flowing to SCP EM.
Could you please help us.
I can’t tell without seeing your configuration. Did you test your channel connection? Is it successfully connecting?
All the connection established but there is no ABAP daemon class is not creating with channel name.
this is the one we are missing.
could you please help on this
Try these troubleshooting steps:
Go back to your Eventing Configuration -> "Maintain Event Topics" select your channel and remove all assigned topics. Save the channel. Add all the needed topics again to your channel and save once again.
Test it again.
Yes all those are available
Please find the below snapshot
But messages are not appearing in Cloud foundry trail account.
But if we try through postman messages are appearing in CF.
Could you please help
Have you created Destination in CF to connect to your backend system via cloud connector?
Yes , We have connected CF to back end through cloud connector as we can see the source system appearing in the event hub UI in cloud platform. If possible ,Can we connect if something is missing in the config to enable .May be we are just one step away to hit cloud platform.
Only thing is we are not seeing the messages.
Have you created Destination in CF to connect to your backend system via cloud connector? - Yes
We are able to see message in CF if we send from post man using rest API
From S4 hana system not
not message appearing in CF.
no errors in error log
ABAP deamon class is also creating
Thanks Vijay Sharma for the well explained blog post. Everything straight to the point with screenshots - great 🙂
Can any one help me on this enablement of s4 hana events for enterprise messaging .Posted all the steps above what we have done in S4.
We have followed the same steps as mentioned by you in this blog.
However we are unable to receive the messages in the queue on the Enterprise Messaging Service instance on the Cloud foundry. (We are using the dev plan of the SCP trial account for the creation of the Enterprise Messaging Service Instance).
But when we change the Business Partner via t-code, it does not trigger any message on the EMS on CF.
Hi Vijay ,
We are following the below blog for :
We are able to get the message count on the queue on the enterprise messaging instance. And we are even able to get the original message via the URL fired using postman as suggested in the above blog.
However, at the moment we are only able to retrieve the last message which was received in the queue. Is there an API that can help me retrieve all the messages in the queue at a time?
Hi Vijay Sharma ,
I am facing trouble establishing RFC connection from my S/4 system to EMS in SCP . I followed all the steps as mentioned in this blog, but I still get connection refused error . I have uploaded all the certificates.
Thanks & Regards,
Have you uploaded the certificates to the SSL Client Anonymous? I had to do so as it seems that the OAuth Clients seems to use that store. Only after I've imported the certificates there it worked. If you still have issues check the trace file of transaction SMICM.
Hi Vijay Sharma ,
Is this possible to consume the messges which are in EM ? and how
Vijay, wanted to get your thoughts on a specific use case for C4C integration.
We have a client who is live on S4HANA 1909 and is now looking to put in C4C.
For Quote/ Sales Order replication from S4 to C4C, we are being told to use NACE-based output and IDOC/ Message COD_REPLICATE_SALES_ORDER. The major problem with that is we deployed BRF+ based output for our Sales Order outputs. Reverting to NACE would mean rewriting all of sales order outputs forms, and would also be reverting back to an R/3 technology. As you may know, BRF+ doesn't play well with IDOCS to we can't really just add this message to the BRF+ output rules.
Could these events be leveraged to either trigger the generation of the COD_REPLICATE_SALES_ORDER IDOC or perhaps invoke a read of the Quote/Sales order into C4C?
Can you please elaborate on below:
One possible reason I can imagine is the partner function of the output type (EDI channel) which is available by standard, but you can also copy the standard class attached to the application type for sales order into a custom one and influence the receiver of the output. However, it is always important to read standard documentations about limitations around IDoc and BRF+ for the application type.
On your second question about events, my personal opinion is not to mix the IDoc in event-driven-architecture. Better solution(future-proof, may be) would be to 'Push' the events from S/4HANA using enterprise event enablement as described in this blog post and make C4C as a subscriber to the SAP Event Mesh topic in SAP BTP. C4C would then read Sales Order details through standard api available.
Thanks for replying so quickly.
What I have found with the IDOCS is that there seems to be a hard-coding... for BILLING_DOCUMENT you must use the the old NACE reference "RD00" in WE21 even though you are using the BRF+ output type BILLING_DOCUMENT. Same with ORDER_CONFIRMATION and "BA00". It also seems SALES_QUOTATIONS do not support the IDOC channel (perhaps because it is not listed in table APOC_C_CHANNEL.
I do like your proposed approach sending the alert and having the C4C system read the Quotation via a webservice/ API. This seems more appropriate for a modern integration. I am sure the C4C team just ported the old ECC integration (hopefully as a temporary solution until they develop something more like what you proposed).