前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >将SAP C4C Custom BO使用ABSL编写的逻辑通过OData服务暴露出去

将SAP C4C Custom BO使用ABSL编写的逻辑通过OData服务暴露出去

作者头像
Jerry Wang
发布2020-08-28 10:37:55
5610
发布2020-08-28 10:37:55
举报

Suppose you have implemented some logic in a given action of your custom BO via ABSL, it is possible to expose the logic via Custom OData service so that it could be consumed by external applications. Custom BO:

代码语言:javascript
复制
import AP.Common.GDT as apCommonGDT;
import AP.FO.BusinessPartner.Global;

businessobject TestBO {
  [Label("Agreement ID")] [AlternativeKey] element AgreementID:ID;
  [Label("Start Date")] element StartDate:Date;
  [Label("Close Date")] element CloseDate:Date;
  [Label("Duration")] element Duration:NumberValue;
  [Label("IsOverDue")] element IsOverDue:Indicator;
  action Calculate;
}

And the logic of Calculate action is very simple, just make comparison between current date and the close date. If the current instance is over due, also store the duration to field “Duration”.

代码语言:javascript
复制
import ABSL;
import AP.PC.IdentityManagement.Global;
import AP.FO.BusinessPartner.Global;

var current = Context.GetCurrentGlobalDateTime( );
var close = this.CloseDate.ConvertToGlobalDateTime();
this.IsOverDue = current.GreaterThan(close);
this.Duration = 0;
if( this.IsOverDue ){
   this.Duration = current.Delta(close).ConvertToDays();
}

Then go to work center Administrator->OData Service Explorer, create a new Custom OData Service:

Create a new function import for this OData service, choose Action as import type, specify “DueCheck” as import name, and bind the BO action Calculate to this function import.

Now test the function import via this BO instance below:

first get its object id by Agreement ID via OData filter operation:

https:///sap/c4c/odata/cust/v1/zjerrytestodataservice/TestBORootCollection?$filter=AgreementID eq ‘JERRY2’ Then execute the url appended with the object id found in previous step plus the function import name: https:///sap/c4c/odata/cust/v1/zjerrytestodataservice/DueCheck?ObjectID=’00163E20C98D1EE7A6BD2FF6E7D3F03F’, and the BO action is successfully executed: you could observe the flag isOverDue and field Duration are correctly calculated and returned by this OData service.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-08-27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档