I had gone through multiple blog post and had not seen any blog post where it have given details how to send data from SAP HANA system to third party system through odata service based on Event configuration .
Event based triggering is commonly used to trigger work flows and in some cases for sending data to third party via proxy interface etc . As we are working with updated version of SAP and Odata services are commonly used for integration now a day, so we can used odata service to send data via CPI to third party system in integration process.
Here, In this blog post , I am going to share how to create a simple odata service and trigger GET event for Purchase order data based on Event configurations.
I tried to explain this document in Three steps :
Step 1 . creation of Odata service to get data
Step 1. Go to transaction code – SEGW .
For detail steps , you can refer my previous post where all steps are mentioned to create Odata service . Here I am just giving brief over of steps for odata creation.
Click on Icon Create. A pop window will appear , Fill the details as per below mention in screen shot and click on check icon or enter.
Now we are going to define structure of work area and internal table , Right click on Data model select import and select DDIC structure.
Here give the details of structure and structure name as per your name conventions.
Select radio button Entity type and and click on check box entity set. fill ABAP structure as EKKO and click on next.
Now you will get the pop up screen with EKKO table fields name. Select fields for your structure and click on next.
Other window will appear where we have to select the key field. tick on EBELN as key field and click on finish. You may get warning message , it can be totally ignored.
click on Save button at the top of menu bar
Now click on generate Icon, A pop up window will appear with class details , click on tick icon and proceed further. It will ask for package , give details and proceed further . These are also knowns as runtime artifacts.
Now we will add this odata service. Go to transaction code /IWFND/MAINT_SERVICE .
Click on push button Add services .
Now double click on your project name service . A pop up window will appear , enter the package details and click on tick icon. An Information message will be shown where it will confirm about the service is created and metadata loaded successfully
Now ,Go to tcode SEGW and open folder Runtime Artifacts , We can See MPC and DPC classes in that.
MPC – This is used to define model. you can use the method Define to create entity, properties etc using code based implementation.
DPC – used to code your CRUDQ methods as well as function import methods. you write all your logic in redefined methods of DPC extension class.
Now in DPC class , in method GET_ENTITY we need to write our logic for getting data in odata structure, Here I had added a simple select SQL to get EKKO data as shown below .
Step 2. Creation of Event for PO change and Custom Function module to Call odata service
Now , we will be creating a custom Function module to map for Business object event.
create custom function module with below parameters to capture event and Object id .
Now Write the below logic in side the FM, pass your odata service URL with the Object id as shown below to create Query URL.
Now, Write a code to call your odata service to get data for PO .
Code is ready in Function Module to get the details for Purchase order based on object id received on event trigger.
We will map this Function Module in Event configurations now.
In transaction SWEC, Map the event as shown below
In Transaction SWE2, Map the Event details as shown below
Save the data .
Step :3 to trigger odata service call.
CPI can map this Odata service to send data to third party. We are triggering Odata to get the data for Purchase order based on event configured .
This FM will be triggered once there is change in PO data, Now let's test FM
in Se37 , Execute FM with below details
After Execution , Check in Transaction /IWFND/APPS_LOG to check your odata service is triggered . In our case it is triggered and in success status as shown below.
Here , We had completed process to trigger Odata Service to send data based on Event Configuration.
In this document, We had create an odata service to get PO details. We had created a custom function module based for event configuration and added logic to call our odata service to get Purchase order details. We had done the Event configuration to trigger our custom function module. Tested the function module to check if odata service is triggered and checked the status for odata service .