欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法

程序员文章站 2022-05-18 10:04:50
...

My series of Cloud Application Studio Blogs

Customer has requirement that code list for field Function in Contact creation page should be restricted based on the role code in Account TI.

SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法

Technically the control field above is modeled in this field as below: ( in BO BusinessPartner )

SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法

And the restricted field Function is in another BO: BusinessPartnerRelationship

SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法

In this case it is not possible to use the RoleCode field to control the Function field.

SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法

Fortunately besides Business Field, it is supported to use an extension field to perform CLR( Code List Restriction ) as well.
Here below are detailed steps:

(1) Create an extension field with indicator data type on Root node of BusinessPartnerRelationship:

SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法

(2) Create an AfterModify event implementation to manually copy the value of RoleCode from BusinessPartner BO to the indicator extension field:

SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法

import ABSL;
import AP.FO.BusinessPartner.Global;

var bpID = this.ContactPerson.ToRoot.FirstBusinessPartner.InternalID;
var queryByID = Customer.QueryByIdentification;
var queryByIDParameter = queryByID.CreateSelectionParams();

queryByIDParameter.Add( queryByID.InternalID, "I", "EQ", bpID );
var result = queryByID.Execute(queryByIDParameter);
var first = result.GetFirst(); 

var common = first.Common.GetFirst();
var RoleCode = common.ToRoot.CustomerRole.RoleCode.content;

if( RoleCode == "BUP002" ){ // prospect
	this.ZRoleIndicator = true;
}
else{
	this.ZRoleIndicator = false;
}

(3) Add this extension field to Quick Creation UI via Extensibility Explorer:

SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法
SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法
SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法

(4) Now it is ready to create a code list restriction based on this indicator extension field: it is now available in Control Field drop down list:

SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法

Just define corresponding value for Prospect ( indicator equals to true ) and Customer ( indicator equals to false ):

SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法

And it works in the runtime: in contact creation page, only a subset of specified entries in CLR maintenance UI is displayed.

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
SAP Cloud for Customer CLR(Code List Restriction)的一种高级用法