使用ABAP代码消费SAP Cloud for Customer的OData服务

In this blog, I will demonstrate how to create a new Opportunity by consuming C4C standard OData service via ABAP code.

The related OData service for Opportunity with detailed explanation on its entity types could be found from SAP help:


使用ABAP代码消费SAP Cloud for Customer的OData服务


I will use a HTTP POST request to finish the creation. A example about how to organize post body could be found from C4C OData development guideline, where ServiceRequest is used for demonstration. I just make minor changes to make it also works on Opportunity.

First I test it in postman to ensure the successful creation:


使用ABAP代码消费SAP Cloud for Customer的OData服务


I paste my http request body text here for your reference:

使用ABAP代码消费SAP Cloud for Customer的OData服务

And a new opportunity could successfully be created in postman:


使用ABAP代码消费SAP Cloud for Customer的OData服务


Now all I need to do is just to translate the activities I have done in postman into ABAP code.


I wrote an ABAP report to create Opportunity by consuming OData service:

使用ABAP代码消费SAP Cloud for Customer的OData服务

Execute the report, new opportunity could be created and found in system:


使用ABAP代码消费SAP Cloud for Customer的OData服务


Source code for ZCL_ODATA_TOOL:

使用ABAP代码消费SAP Cloud for Customer的OData服务使用ABAP代码消费SAP Cloud for Customer的OData服务使用ABAP代码消费SAP Cloud for Customer的OData服务使用ABAP代码消费SAP Cloud for Customer的OData服务

Further reading

You can find a list of all other blogs related to OData written by Jerry.


Consume standard C4C OData service via ABAP code

Leverage C4C Odata notification to monitor C4C Opportunity change in CRM system

OData Service backend implementation in C4C, CRM and S4 HANA

JMeter beginner – how to use JMeter to measure performance of OData service accessed parallelly

Regarding cookie manipulation in CL_HTTP_CLIENT to avoid CSRF token validation failure issue


上一篇:win10 uwp 使用 asp dotnet core 做图床服务器客户端


下一篇:公司网站渗透测试服务过程分享