Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
umang6287
Participant
Now that you're aware of the scenarios where leveraging Advanced Event Mesh can offer significant benefits, you might be eager to give it a try. That's why I've prepared this blog to assist you in getting started with AEM in conjunction with the On-premises SAP system to publish the messages.

 

Getting started with SAP AEM (Solace PubSub+)


You can go through the document at below URL to get started.

https://help.pubsub.em.services.cloud.sap/Cloud/ggs_signup.htm

 

To get the trial version of the SAP Integration Suite, advanced event mesh.  Go to https://solace.com/ and Select the option Get PubSub+ for Free that you will find in the right upper corner.


You will get two options.


 

Select “Get started with Cloud.”  Fill up the form and sign up.

 

Create a first broker service


 

Follow the steps highlighted in the SAP Help document for AEM

https://help.pubsub.em.services.cloud.sap/Cloud/ggs_create_first_service.htm

 

 

Create a Restful connection with the on-premises SAP system


 

Create a new RFC destination of type “G” (HTTP Connection to External Server).

  • Transaction: SM59

  • Create a new destination of type “G”

  • Specify Target Host and Service No.(Port): endpoint for the SAP Advanced Event mesh




You find the details at below path in AEM.

Select cluster manager and Go to the broker you want to connect.

 




Credentials or certificates for authentication can be specified on tab Logon & Security:


Browser-specific way to get a certificate.

Step 1: Open the host URL with port to your browser and click on the padlock –> Connection is secure.

Step 2: Click on Certificate is valid.



Step 3: Got to the Details tab and export the file in order to save it.


In the next step, this certificate can be added to the Trust Store in SAP.

Add Certificates to Trust Store

  • Transaction: STRUST

  • Select Certificate Listas used in the RFC destination created above

    1. Click the button Import certificate.

    2. Click the button Add to Certificate List





 

Set up the queue

 

Follow the steps outlined here: https://help.pubsub.em.services.cloud.sap/Cloud/ggs_queue.htm

 

Create a topic following the event designer steps at the below URL

Follow the steps outlined here: https://help.pubsub.em.services.cloud.sap/Cloud/Event-Portal/get-started-event-portal-designer.htm

 

Implement a Sample code to trigger the message!

Once the above steps are complete, create a program using this sample code.

 

*&---------------------------------------------------------------------*
*& Report Z_TEST_SOLACE_AEM
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT z_test_solace_aem.

DATA:  l_query TYPE string,

l_body TYPE string,

l_token TYPE string,

l_result TYPE string.

DATA: lo_http_client TYPE REF TO if_http_client.

PARAMETERS : p_msg TYPE char255.

* Create the HTTP CLient

CALL METHOD cl_http_client=>create_by_destination

EXPORTING

destination              = 'SOLACE_AEM' " This is the name of destination in your system

IMPORTING

client                   = lo_http_client

EXCEPTIONS

argument_not_found       = 1

destination_not_found     = 2

destination_no_authority = 3

plugin_not_active            = 4

internal_error                   = 5

OTHERS                          = 6.

IF NOT sy-subrc IS INITIAL.

ENDIF.

* create the URI for the client.

l_query = '/solaceaem/' . " This is the name of event/topic in AEM

CALL METHOD cl_http_utility=>set_request_uri

EXPORTING

request = lo_http_client->request

uri     = l_query.

* update the HTTP Method

CALL METHOD lo_http_client->request->set_method

EXPORTING

method = lo_http_client->request->co_request_method_get.

* set Content type

CALL METHOD lo_http_client->request->if_http_entity~set_content_type

EXPORTING

content_type =  'application/json'.

* set header field for fetching X-CSRF token

CALL METHOD lo_http_client->request->set_header_field

EXPORTING

name  = 'X-CSRF-Token'

value = 'Fetch'.

*Step 3:- Trigger the GET Method

lo_http_client->send(

EXCEPTIONS

http_communication_failure = 1

http_invalid_state         = 2 ). "Send the HTTP request

lo_http_client->receive(

EXCEPTIONS

http_communication_failure = 1

http_invalid_state         = 2

http_processing_failed     = 3 ). "receive the response

****GET x-csrf TOKEN from earlier response

CALL METHOD lo_http_client->response->get_header_field

EXPORTING

name  = 'X-CSRF-Token'

RECEIVING

value = l_token.

*Step 4:- Fill headers and Body for HTTP POST method

* Set X-CSRF- Token in the new request.

CALL METHOD lo_http_client->request->set_header_field

EXPORTING

name  = 'X-CSRF-Token'

value = l_token.

* update the HTTP Method

CALL METHOD lo_http_client->request->set_method

EXPORTING

method = lo_http_client->request->co_request_method_post.

****content type

CALL METHOD lo_http_client->request->set_content_type

EXPORTING

content_type = 'application/json'.

CONCATENATE '{ "Message" : "' p_msg '" }' INTO l_body.
CALL METHOD lo_http_client->request->set_cdata

EXPORTING

data = l_body.

lo_http_client->send(

EXCEPTIONS

http_communication_failure = 1

http_invalid_state         = 2 ). "Send the HTTP request

lo_http_client->receive(

EXCEPTIONS

http_communication_failure = 1

http_invalid_state         = 2

http_processing_failed     = 3 ). "receive the response

l_result = lo_http_client->response->get_cdata( ).

WRITE:/ l_result.

 

What can you expect in the next blog?

Embed this custom program into the FM and propagate events outside the system to publish at the AEM broker.

 

 

 

 

 
3 Comments
Labels in this area