Document flow API in SAP CRM and C4C

Document flow API in CRM

以一个具体的例子来说明。在Appointment的Overview page上能看见一个名叫Reference的区域,这里可以维护一些其他的业务文档的ID,这样可以将该业务文档同当前正在编辑的Appointment关联起来。

《Document flow API in SAP CRM and C4C》

我写了一个简单的报表来演示如何用ABAP代码给这个Reference区域的字段赋值,背后用到的实际上就是CRM Document flow相关的API. 报表的源代码在我的github上:

代码的核心就是使用CRM One Order的function module CRM_ORDER_MAINTAIN, 把document flow相关的数据传入到changing参数ct_doc_flow里。

《Document flow API in SAP CRM and C4C》

这个ct_doc_flow的内容生成逻辑如下。既然是Document Flow,必然涉及到两个document,在API里用后缀为A和B的字段来存储,如下图绿色区域所示。这些字段需要分别存储两个document的GUID和BOR类型。

《Document flow API in SAP CRM and C4C》

假设我执行report时指定的Opportunity的ID是888,那么report成功执行后,我能在References区域看到如下的字段。Opportunity的ID和描述信息已经能够正常显示了。

《Document flow API in SAP CRM and C4C》

同时在Transaction History区域也能看到该关联关系:

《Document flow API in SAP CRM and C4C》

Document flow API in C4C

假设我需要在Cloud Application Studio里开发一个功能,允许客户能够手动将两个Ticket关联起来。

1. 在Ticket的BO ServiceRequest上创建一个新的action linkTicket用于实现关联逻辑。同时创建一个新字段用于存储需要关联的Ticket ID:

《Document flow API in SAP CRM and C4C》

通过Cloud Application Studio将这个新字段配到UI上,同时在工具栏里新增一个按钮,绑定到BO的action linkTicket上。

《Document flow API in SAP CRM and C4C》

《Document flow API in SAP CRM and C4C》

Action的实现代码:

import ABSL;

var eleBTD: elementsof ServiceRequest.BusinessTransactionDocumentReference;

eleBTD.BusinessTransactionDocumentReference.ID.content = this.refTicket;

eleBTD.BusinessTransactionDocumentReference.TypeCode = "118"; // type code of BO ServiceRequest

eleBTD.BusinessTransactionDocumentRelationshipRoleCode = "2"; // Successor document

this.BusinessTransactionDocumentReference.Create(eleBTD);

2. 假设我想把Ticket 3638和Ticket 3622关联起来,我需要打开Ticket 3638,在新字段Reference Ticket里手动输入3622,然后点击按钮Link Ticket.

《Document flow API in SAP CRM and C4C》

成功执行之后,在Ticket的Document Flow tab即可看到这个关联关系。

《Document flow API in SAP CRM and C4C》

    原文作者:JerryWangSAP
    原文地址: https://segmentfault.com/a/1190000013375594
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞