使用OData服务将SAP C4C自定义BO的TextCollection暴露给外部消费者-阿里云开发者社区

开发者社区> 开发者小助手-bz4> 正文

使用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


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
排名前 16 的 Java 工具类,哪个你没用过?
在Java中,实用程序类是定义一组执行通用功能的方法的类。 这篇文章展示了最常用的Java实用工具类及其最常用的方法。类列表及其方法列表均按受欢迎程度排序。数据基于从GitHub随机选择的50,000个开源Java项目。 希望您可以通过浏览列表来了解
8 0
ECS使用感受
阿里云服务器初体验
3 0
ECS初体验
esc简单的初体验
4 0
Java 强、弱、软、虚,你属于哪一种?
Java中的四种引用 Java中有四种引用类型:强引用、软引用、弱引用、虚引用。
3 0
微服务架构 | *2.3 Spring Cloud 启动及加载配置文件源码分析(以 Nacos 为例)
Spring Cloud 要实现统一配置管理,需要解决两个问题:如何获取远程服务器配置和如何动态更新配置;在这之前,我们先要知道 Spring Cloud 什么时候给我们加载配置文件;
3 0
Java 强、弱、软、虚,你属于哪一种?
Java中的四种引用 Java中有四种引用类型:强引用、软引用、弱引用、虚引用。
3 0
微服务架构 | *2.4 Nacos 获取配置与事件订阅机制的源码分析
为方便理解与表达,这里把 Nacos 控制台和 Nacos 注册中心称为 Nacos 服务器(就是 web 界面那个),我们编写的业务服务称为 Nacso 客户端; 由于篇幅有限,这里将源码分析分为上下两篇,其中上篇讲获取配置与事件订阅机制,下篇讲长轮询定时机制;
4 0
ECS使用体验
使用阿里云服务器搭建个人博客网站
4 0
冬季实战营第一期学习报告
1月17至22日,我有幸参加了阿里云组织的“冬季实战营第一期:从零到一上手玩转云服务器”抱着期待和学习的心情,我参与其中,经过训练,收益良多、颇有收获
6 0
C# 同步 异步 回调 状态机 async await Demo
C# 同步 异步 回调 状态机 async await Demo 我们项目的客户端和服务端通信用的是WCF,我就想,能不能用异步的方式调用WCF服务呢?或者说能不能用async await的方式调用WCF服务呢?
6 0
2315
文章
0
问答
来源圈子
更多
+ 订阅
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载