使用OData服务将SAP C4C自定义BO的TextCollection暴露给外部消费者

简介: 使用OData服务将SAP C4C自定义BO的TextCollection暴露给外部消费者

In the last part of my blog Step by step to enable Text Collection for your custom BO I mentioned it is possible to create a web service in Cloud Application studio which contains a read operation, to return the Text Collection data to web service consumer. However the read operation can only support single BO instance ID as operation input parameter – on the other hand query operation does support multiple BO instance ID to fulfill the mass-handling requirement, however unfortunately it is not possible for query created in Cloud studio to directly return the transaction data of Text Collection. As a result we have to seek alternative.


The requirement to return text collection belonging to multiple BO instances could be achieved by C4C OData consisting of two steps.


Suppose I have two Custom BO instances JERRYORDER1 and JERRYORDER2, each has maintained their own Text Collection data:


image.png

The definition of my custom BO:

image.png

Here below are two necessary steps to return the Text Collection of these two BO instances via custom OData service.


(1) Create a new Custom OData Service in Work center Administrator, view OData Service Explorer, make sure you have selected Dependent object TextCollection:

image.png

Get the Object ID of the two BO instances by performing fitlering against their alternative key, in my custom BO the alternative key is MainBOID.


Create a new HTTP Get request in Chrome extension Postman with url:


https:///sap/c4c/odata/cust/v1/jerrylongtextodata/MainBORootCollection?$filter=MainBOID eq ‘JERRYORDER1’ or MainBOID eq ‘JERRYORDER2’


image.png

write down the Object ID of these two BO instances from response:

image.png

(2) Create a HTTP post request in Postman:

image.png

Paste the following text as post body. In the post body, the Object ID of two BO instances fetched from previous step are used as input parameter of two embedded HTTP GET operation contained in the batch request.

image.png

Execute this post request in Postman, and the TextCollection for the two BO instances will be returned in a SINGLE roundtrip.

Response for BO JERRYORDER2:


image.png

Response for BO JERRYORDER1:

image.png

Note

(1) If you have too many BO instances for which you would like to query their ObjectID by alternative key for subsequent query operation, it means you have to append a lengthy string like $filter=MainBOID eq ‘JERRYORDER1’ or MainBOID eq ‘JERRYORDER2’ or …. MainBOID eq ‘JERRYORDERN’ as HTTP Get request url. It is possible that the url will exceed the maximum length of a URL for HTTP Get.


In this case you can avoid it by using HTTP Post instead:


image.png

HTTP post body for doing filter operation on multiple BO instances:

image.png

You will get the same result as using HTTP get with url:

image.png

(2) In case you need to develop a Java Program to achieve the above mentioned two steps, you can find sample code in my blog OData service parallel performance measurement – how to deal with XSRF token in Java Program and JMeter.


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

OData service parallel performance measurement – how to deal with XSRF token in Java Program and JMeter

Expose TextCollection data belonging to a Custom BO via OData service


相关文章
|
2月前
|
缓存 UED
关于 SAP OData Annotation Provider Class 以及 metadata 模型注册的事务码
关于 SAP OData Annotation Provider Class 以及 metadata 模型注册的事务码
26 0
|
3月前
|
XML API 数据格式
SAP 标准 OData 服务 CATALOGSERVICE;v=2 的作用介绍
SAP 标准 OData 服务 CATALOGSERVICE;v=2 的作用介绍
24 0
|
3月前
|
监控 前端开发 数据可视化
SAP 标准 OData 服务 ABAP_REPOSITORY_SRV 的作用介绍
SAP 标准 OData 服务 ABAP_REPOSITORY_SRV 的作用介绍
31 1
|
1月前
|
数据库 开发者 容器
SAP OData metadata.xml 里 EntityType,EntitySet 和 EntityContainer 三个概念之间的区别和联系
SAP OData metadata.xml 里 EntityType,EntitySet 和 EntityContainer 三个概念之间的区别和联系
24 0
|
3月前
|
API
SAP Fiori Elements 针对 OData V2 和 V4 的 Extension API
SAP Fiori Elements 针对 OData V2 和 V4 的 Extension API
26 0
|
3月前
|
缓存 搜索推荐 开发者
关于 SAP 标准 OData 服务 /sap/bc/adt/ato/settings 的作用
关于 SAP 标准 OData 服务 /sap/bc/adt/ato/settings 的作用
36 0
|
5月前
|
API
SAP OData V2 和 V4 里针对日期类型的字段进行过滤操作(filter)的正确语法试读版
SAP OData V2 和 V4 里针对日期类型的字段进行过滤操作(filter)的正确语法试读版
36 1
|
6月前
|
数据采集 供应链 搜索推荐
什么是 SAP OData Annotations 的 metadata extension files
什么是 SAP OData Annotations 的 metadata extension files
39 0
|
6月前
|
Web App开发 资源调度 开发者
SAP Fiori Elements 应用 OData 元数据请求 url 里的模型名称决定逻辑
SAP Fiori Elements 应用 OData 元数据请求 url 里的模型名称决定逻辑
49 0
|
1月前
|
前端开发 搜索推荐 开发者
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
27 0