首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >使用SAP C4C自定义BO association创建动态下拉列表

使用SAP C4C自定义BO association创建动态下拉列表

作者头像
Jerry Wang
发布2020-08-31 11:28:30
5820
发布2020-08-31 11:28:30
举报

My series of Cloud Application Studio Blogs

  • How to detect EditMode in an Embedded Component
  • Step by step to enable your custom BO with attachment upload functionality
  • Step by step to create an Adobe Print form in Cloud application Studio
  • How to render PDF which displays picture from the image attachment of your custom BO
  • How to get current logged on business user’s employee information and assigned organization unit via ABSL
  • How to implement dynamic access control based on custom BO using OWL
  • How to make Code List Restriction work when control field and restricted field are not on the same BO
  • How to implement custom number range using custom business object
  • Two approaches to create Code List in Cloud Studio
  • Create Dynamic Code List via Custom Business Object Association
  • Create Dynamic Code List via Custom Business Object Association

In my previous blog Two approaches to create Code List in Cloud Studio I introduce two different approaches to build Code List via Cloud Application Studio. Both solution will finally create dedicated data type under the hood for Code List.

In this blog, I will introduce the third approach to build a kind of dynamic Code List without using dedicated data type. Dynamic Code List means for the same BO, instance A could have drop down list for example 1,2,3 and another instance B has list as A, B, C. In productive scenario this dynamic behavior could be helpful if you would like to achieve that different BO instance has different Code List based on their transaction type for example.

The main idea of this solution is to use a dedicated Business Object serving as the data source of the Code List defined in a Hosting BO. So we have to create these two BOs separately.

(1) Create a Code List BO:

import AP.Common.GDT as apCommonGDT;
businessobject JerryCodeList {
   [AlternativeKey] element CodeListBOID: ID;
   node CodeList[0,n] {
      element Code:NumberValue;
      element CodeText: LANGUAGEINDEPENDENT_ENCRYPTED_EXTENDED_Name;
   }
}

Activated the BO and create the corresponding UI. In OWL I can list all existing Code List instance:

In Thing Inspector UI, use AdvancedListPane to allow users to maintain Code List entries:

Now for Code List instance JERRY1, I have three entries maintained:

And for JERRY2, I have four entries maintained:

(2) Create a host BO, which should have one field holding the reference to the corresponding Code List BO. Within this BO, define an association to Code List BO.

import AP.Common.GDT as apCommonGDT;
businessobject MainBO {
	[AlternativeKey] element MainBOID: ID;
        element OrderName: LANGUAGEINDEPENDENT_ENCRYPTED_EXTENDED_Name;
        element OrderStatus: NumberValue;
	element CodeListBOID: ID;
	association ToCodeList [0,1] to JerryCodeList using CodeListBOID;
}

Create AfterModify event and implement the association there:

import ABSL;
if( !this.CodeListBOID.IsInitial() && !this.ToCodeList.IsSet() ){
	var codeListQuery = JerryCodeList.QueryByElements;
	var para = codeListQuery.CreateSelectionParams();
	para.Add( codeListQuery.CodeListBOID, "I", "EQ", this.CodeListBOID);
	var result = codeListQuery.Execute(para);
	this.ToCodeList	= result.GetFirst();
}

(3) In the Thing Inspector UI of the host BO, create a new Data List and bind it to the CodeList node in BO model. Bind data field Code and CodeText accordingly as displayed in the screenshot below.

The OrderStatus field in Data structure should be bound to BO field OrderStatus as well. And the CCTS Information and CodeList properties for the data field should be set as below.

The last step: bind the UI element to the OrderStatus field.

Once done, when you create BO instance A and bind it to Code List instance JERRY1,

it will have Code List from JERRY1:

The same logic works for instance B which displays Code List from JERRY2:

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

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

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

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

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • My series of Cloud Application Studio Blogs
相关产品与服务
Cloud Studio(云端 IDE)
Cloud Studio(云端 IDE)是基于浏览器的集成式开发环境,为开发者提供了一个稳定的云端工作站。用户在使用 Cloud Studio 时无需安装,随时随地打开浏览器即可使用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档