A Step by Step process to trigger Odata Service to send data based on Event Configuration in SAP HANA
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.
In my previous blog Post ,
We had learn about how to create a Odata service and test the response. Follow the link for odata creation – https://blogs.sap.com/2021/05/06/a-step-by-step-process-to-create-odata-services-in-sap-sap-hana-system/
And Post method for odata service : follow the link for odata post method creation – https://blogs.sap.com/2021/05/19/a-step-by-step-process-to-post-odata-services-in-sap-sap-hana-system/
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.
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 .
Now Activate all the changes related to your DPC class , go back to odata project ,Click on Generate icon again. Now Your odata service is ready to get the data for PO. to test this service you can follow my previous Odata service blog post –https://blogs.sap.com/2021/05/06/a-step-by-step-process-to-create-odata-services-in-sap-sap-hana-system/
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 .
Thanks Very useful
Thanks for this Laxmi.
We can get EDMX file from odata metadata structure. In CPI , We need to used Odata sender adapter where you need to upload this EDMX file.
When I maintain the interface in CPI with Sender OData having EDMX loaded, I get a CPI endpoint, which I believe should be configured in SAP.
In the case of SOAP Services, we do that in SOAMANAGER.
The question I have is, where do we configure the CPI Endpoint in SAP so that when the ODATA is triggered in SAP, CPI interface (iFlow) is called and executed!
End point connection need to be configured in SAP HANA cloud connector under Administration.
Thanks again Laxmi.
Sorry, but I am still not very clear.
I hope we are talking about the interface where SAP being the Source, executes the OData Service and calls CPI Interface, which then calls 3rd party System.
For Outbound Connection (SAP-->CPI--->3rd Party), we don't use SAP Cloud Connector (SCC). SCC is used when CPI makes a call to SAP (3rd Party-->CPI-->SCC-->SAP).
Am I still missing anything here? I am looking for a link between SAP OData and CPI Interface where SAP is pushing data.
If you are using CPI then you can check the Standard I-flow provided by SAP. Example- SAP Commerce Cloud Integration with SAP Marketing Cloud - Artifact-> Replicate-Customer-from-SAP-Commerce-Cloud-to-SAP-Marketing-Cloud. Here you can see SAP had used Odata sender adapter.
You can also refer one of the artifacts i.e. Value-Mapping-Between-SAP-Commerce-Cloud-and-SAP-Marketing-Cloud for configurations. These configurations are mostly done by Admin team.
You can also find the configuration guide in document section.
Hi laxmi jibhe,
As previously mentioned by Anuj, we are trying to send data out of SAP and in this case, we don't have cloud connector option and as per your previous reply, we know that in artifacts OData sender adapter has been used but these Artifacts generate an end point which somewhere needs to be provided within SAP so that data can be pushed out from SAP via this end point and data can reach to CPI.
Can you please check this and let me know how to resolve this.
When you expose the OData service in SAP or in Gateway system, you can create a scheduler in SAP CPI iFlow and invoke this exposed OData service. Also, your SAP system or the Gateway system needs to be configured in SCP via Cloud Connector and the virtual system name needs to configured in CPI.
If you need to invoke CPI endpoints on an event based in SAP, then you need to use Proxy service where you can configure the CPI endpoints in SOAMANAGER.
Hope this clarifies your doubt.
Thanks for this Raja. This helps.
So, as per your first comment, we can have a PULL from CPI, which I understand.
For pushing the message, can you please expand below please. Do we need to create a Consumer proxy like we do for SOAP Services Outbound cases? and if yes, how is that tagged with OData API Trigger? I would appreciate if you can expand the sequence of events that will occur in this case.
'If you need to invoke CPI endpoints on an event based in SAP, then you need to use Proxy service where you can configure the CPI endpoints in SOAMANAGER.'
Hi laxmi jibhe,
Can you please address the concerns raised by Anuj as I also have similar concern.
when the material document is posted in MIGO, we are trying to send the data to the CPI through odata, where we are trying to trigger Odata Service to send data based on Event Configuration in SAP HANA I have followed the above steps, But I got stuck at the point "mapping this Function Module in Event configurations" in SWEC where we couldn't be able to know what Change document object need to be assigned for the event to trigger our custom function module.
I would also like to ask how the CPI come to know what material document need to be triggered to get respective data.
Can you please check this and let me know how to resolve this.
Hi Laxmi ,
I have tried your all the steps which you mentioned ,but in my project we have gateway client as 'GFD' and Development client as 'S4D-800'.
When I use me22n tcode and trying to change then my FM get call but through FM when odata get call that time I am getting 401 'unauthorized error ' and sap netweaver login pop up comes, how do I handle it and where did you mention RFC destination in your steps so that I can call it through RFC DESTINATION in same way as my basis person asking me which rfc destination are you using OR do we require RFC destination in our function module please let me know.
Note : Should I create abap destination or http destination in our case please let me know so that I will follow as you say.
Thanks & Regards
WHo does these .ABAPer. What ar ethe steps from BASIS COnfiguration ?
Are we able to trigger ODATA based services at the save of the Sales Order via NACE output or using the new S4 Output Management ?
Hi Laxmi, Thanks for the blog.
I need to trigger PM notification from ECC system to PI/PO. I was following your blog and now the OData is getting called when a new notification is created/changed.
My question is how can I pass these data into PI/PO, how to integrate your solution with PI/PO.