专栏首页Jerry的SAP技术分享将SAP C4C Custom BO使用ABSL编写的逻辑通过OData服务暴露出去

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

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:

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”.

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.

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • SAP Spartacus ProductOccModule

    这个defaultOccProductConfig主要是endpoint config:

    Jerry Wang
  • Angular应用里使用import直接导入到应用代码里的class,在运行时的表现

    很有意思的是,在Chrome开发者工具里无法直接显示这个从import里导出的“变量”:

    Jerry Wang
  • SAP ABAP ST05 trace和SAP HANA studio planViz的性能差异

    execute report ZCRMS4_ORDER_SEARCH_PROD_SOLD with variant ISSUE:

    Jerry Wang
  • 纪念错误的理解单点登录

    错误理解了单点登录的概念老长时间,原因为只允许单用户登录系统就叫单点登录,度娘说我理解错了,这才真正明白嘛叫单点登录。这个例子是按照以前错误的理解来想的“单点登...

    西门呀在吹雪
  • ImportError: cannot import name ‘audio_ops‘ (TensorFlow)

    tensorflow 报错: from tensorflow.python.framework import ops as tf_ops

    于小勇
  • iOS-Core系列框架介绍(二)

    用户2215591
  • jmeter参数化csv+用户参数配合(请求加密,返回解密)

    1. 所有的接口都经过网关,意味着:入参和出参都需要加密,是所有的参数而不是单个参数的加密;

    java乐园
  • 生成lua的静态库.动态库.lua.exe和luac.exe

    前些日子准备学习下关于lua coroutine更为强大的功能,然而发现根据lua 5.1.4版本来运行一段代码的话也会导致 “lua: attempt to ...

    晚晴幽草轩轩主
  • win10 安装 MySQL8.0版本

    我下载的是Windows (x86, 64-bit), ZIP Archive,主要是网不好,下载慢,所以选择第一个,

    青年码农
  • 大牧絮叨设计模式:原型模式

    原型模式(Prototype)[GOF95]是一种对象的创建模式,通过给定一个参考的原型对象来指定要创建的对象的类型及数据,然后复制该对象创建更多的相同对象的方...

    大牧莫邪

扫码关注云+社区

领取腾讯云代金券