0% found this document useful (0 votes)
59 views4 pages

Event Consumption Model

This document outlines the steps to link the Business Partner in SAP S/4HANA with a custom OData service using an Event Consumption Model. It details enabling event-based communication, creating the model, implementing an event handler, and registering the handler to listen for Business Partner events. Finally, it provides guidance on testing the integration to ensure the OData service receives the event payload correctly.

Uploaded by

amani bougossa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views4 pages

Event Consumption Model

This document outlines the steps to link the Business Partner in SAP S/4HANA with a custom OData service using an Event Consumption Model. It details enabling event-based communication, creating the model, implementing an event handler, and registering the handler to listen for Business Partner events. Finally, it provides guidance on testing the integration to ensure the OData service receives the event payload correctly.

Uploaded by

amani bougossa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

To link the Business Partner in SAP S/4HANA with your custom OData service created in

ABAP Development Tools (ADT), you need to create an Event Consumption Model.
This model listens to Business Partner events and triggers the OData service. Here’s
how you can achieve this:

Step 1: Enable Event-Based Communication for Business Partner

SAP S/4HANA supports event-driven architecture where Business Partner events (e.g.,
create, update, delete) can be captured and consumed.

1. Check the Available Events:


a. Use transaction SWO1 to check the business object BUS1006 (Business
Partner).
b. Alternatively, check available events in SWE2 (Event Linkage).
2. Activate Business Partner Event Handling:
a. Use t-code DRFOUT to configure the event replication for Business
Partner.
b. Set up the necessary filters and replication settings.

Step 2: Create an Event Consumption Model

To consume these events and forward them to your OData service:

1. Go to ADT (ABAP Development Tools in Eclipse).


2. Create a New Event Consumption Model:
a. Open your ABAP package.
b. Right-click and select New → Other → Event Consumption Model.
c. Choose the relevant event source (BO:BusinessPartner) from
S4HANA_BUSINESS_PARTNER.
d. Define a binding to your custom OData service.
3. Define the Event Subscription:
a. Map the event properties (e.g., BusinessPartner ID).
b. Ensure the event contains relevant fields needed by your OData service.
4. Activate and Publish the Model:
a. Once your Event Consumption Model is ready, activate it.
b. Use SRT_MONI to monitor incoming event messages.

Step 3: Implement an Event Handler to Call the OData Service

In case you need to process the event before calling the OData service:
1. Create a New ABAP Class to Handle Events:
a. Implement an ABAP Class (IF_EHUB_SUBSCRIBER interface) to process
Business Partner events.
b. In the event handler, call the OData service using HTTP_CLIENT.
2. Configure the Event Subscription:
a. Use SCP Event Mesh (if using SAP BTP) or create a Destination in SM59
for the OData service.
b. Ensure your OData service is reachable from the S/4HANA backend.

1. Create an ABAP Class for Event Handling

1. Go to ADT (Eclipse) → New ABAP Class.


2. Implement IF_EHUB_SUBSCRIBER to handle event processing:

CLASS zcl_bp_event_handler DEFINITION


PUBLIC
FINAL
CREATE PUBLIC.

PUBLIC SECTION.
INTERFACES if_ehub_subscriber.

PRIVATE SECTION.
METHODS call_odata_service IMPORTING iv_business_partner TYPE
bu_partner.
ENDCLASS.

CLASS zcl_bp_event_handler IMPLEMENTATION.

METHOD if_ehub_subscriber~process_event.
DATA: lt_event_data TYPE STANDARD TABLE OF seocmpname,
ls_event_data TYPE seocmpname,
lv_bp_id TYPE bu_partner.

" Get event data


lt_event_data = event->get_data( ).
LOOP AT lt_event_data INTO ls_event_data.
IF ls_event_data-name = 'BusinessPartner'.
lv_bp_id = ls_event_data-value.
EXIT.
ENDIF.
ENDLOOP.

IF lv_bp_id IS NOT INITIAL.


call_odata_service( lv_bp_id ).
ENDIF.

ENDMETHOD.

METHOD call_odata_service.
DATA: lo_http_client TYPE REF TO if_http_client,
lv_url TYPE string,
lv_json_body TYPE string,
lv_response TYPE string.

" Define the OData service URL


lv_url = 'https://your-system-
url/sap/opu/odata/sap/ZMY_ODATA_SRV/BusinessPartnerSet('''
&& iv_business_partner && ''')'.

" Create HTTP client


CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
IMPORTING
client = lo_http_client.

IF lo_http_client IS NOT INITIAL.


" Set request method
lo_http_client->request->set_method(
if_http_request=>co_request_method_get ).

" Send request


lo_http_client->send( ).
lo_http_client->receive( ).

" Read response


lv_response = lo_http_client->response->get_cdata( ).
WRITE: / 'Response:', lv_response.
ENDIF.

ENDMETHOD.
ENDCLASS.

2. Register the Event Handler

Now, you need to register this handler to listen for Business Partner events.

1. Go to transaction SWE2 (Event Type Linkage).


2. Search for BUS1006 (Business Partner).
3. Add a new entry:
a. Object Type: BUS1006
b. Event: CREATED (or CHANGED)
c. Receiver Type: ZCL_BP_EVENT_HANDLER
d. Check Active box.
4. Save and activate.

Step 4: Test the Integration

• Create or update a Business Partner in BP Transaction.


• Check if the event is triggered using SRT_MONI.
• Verify if your OData service receives the event payload.

You might also like