Several days ago I wrote a blog How to build a drop down list using Smart template + CDS view which introduces how to create a drop down list based on values from a backend table.
For example, the status list in above screenshot comes from the three entries in database table ZSTATUS_FIXEDVAL.
And now a new requirement is to use the fixed value defined in an ABAP domain instead.
Here below are steps to achieve it.
(1) Create an ABAP domain named ZORDER_STATUS_DOMAIN containing status list as displayed in previous screenshot. Then create an ABAP data element based on this domain. Create one header database table as root,
and another database table as item.
(2) create two CDS views based on the two database tables accordingly:
@AbapCatalog.sqlViewName: 'zorheader'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'header view'
define view Z_I_Order_Header as select from zorder_header
association [0..*] to Z_I_Order_Item as _Item
on $projection.object_id = _Item.parent_id
{
key zorder_header.object_id,
zorder_header.description,
zorder_header.order_status,
zorder_header.order_status_text,
@ObjectModel.association.type: #TO_COMPOSITION_CHILD
_Item
}
@AbapCatalog.sqlViewName: 'zorITem'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'order item detail'
define view Z_I_Order_Item as select from zorder_item {
@UI.lineItem : [{position:10, label : 'Parent ID'}]
key zorder_item.parent_id,
@UI.lineItem : [{position:20, label : 'Item Number'}]
key zorder_item.item_id,
@UI.lineItem : [{position:30, label : 'Item Description'}]
zorder_item.item_text,
zorder_item.item_type
}
Then the consumption CDS view:
@AbapCatalog.sqlViewName: 'zjorderview'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Jerry order consumption view'
@Search.searchable: true
@OData.publish: false
@ObjectModel: {
compositionRoot: true,
type: #CONSUMPTION,
transactionalProcessingDelegated: true,
createEnabled,
deleteEnabled,
updateEnabled
}
@UI.headerInfo:{
typeName: 'Jerry Service Order',
typeNamePlural: 'Jerry Service Orders',
title: { value: 'object_id' },
description: { value: 'description' }
}
define view Z_C_Order as select from Z_I_Order_Header {
@UI.lineItem : [{position:10, label : 'Service Order ID'}]
@UI.identification: [ { position: 10, label : 'Service Order ID' } ]
@Search:{ defaultSearchElement: true, ranking: #HIGH, fuzzinessThreshold: 0.8 }
@UI.selectionField: [ { position: 20, label : 'Service Order ID' } ]
key Z_I_Order_Header.object_id,
@UI.lineItem : [{position:20, label : 'Service Order Description'}]
@UI.identification: [ { position: 20, label : 'Service Order Description' } ]
@Search:{ defaultSearchElement: true, ranking: #HIGH, fuzzinessThreshold: 0.8 }
@UI.selectionField: [ { position: 10, label : 'Description' } ]
Z_I_Order_Header.description,
@UI.identification: [ { position: 30, label : 'Order Status' } ]
Z_I_Order_Header.order_status,
Z_I_Order_Header.order_status_text,
@ObjectModel.association.type: [#TO_COMPOSITION_CHILD]
Z_I_Order_Header._Item
}
Now all are done except remaining work in ABAP side.
(3) Create a new project via tcode SEGW and include the activated consumption CDS view created in step2. If you don’t know how to do it, refer to this blog Enable CRM Service Order application with edit functionality.
Generate runtime artifacts. Now both DPC and MPC classes are generated.
3.1 Redefine DEFINE method of your MPC_EXT class:
super->define( ).
zcl_fis_shlp_annotation=>create(
io_odata_model = model
io_vocan_model = vocab_anno_model
iv_namespace = 'sap'
iv_entitytype = 'Z_C_OrderType'
iv_property = 'order_status'
iv_search_help = space
iv_search_supported = abap_false
iv_search_help_field = space
iv_valuelist_entityset = 'OrderStatusEntitySet'
iv_valuelist_property = 'Code' ##NO_TEXT
)->add_display_parameter( iv_valuelist_property = 'Text' ).
data(lo_txt_property) = model->get_entity_type( 'Z_C_OrderType' )->get_property( 'order_status' ).
lo_txt_property->set_value_list( /iwbep/if_mgw_odata_property=>gcs_value_list_type_property-fixed_values ).
data(lo_text_anno) = lo_txt_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).
lo_text_anno->add( iv_key = 'text' iv_value = 'order_status_text').
lo_txt_property = model->get_entity_type( 'OrderStatus' )->get_property( 'Code' ).
lo_txt_property->set_value_list( /iwbep/if_mgw_odata_property=>gcs_value_list_type_property-fixed_values ).
lo_text_anno = lo_txt_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' ).
lo_text_anno->add( iv_key = 'text' iv_value = 'Text').
The code above will generate the highlighted annotations which could be found in metadata:
3.2 Since in 3.1, the entity set OrderStatusEntitySet and entity type OrderStatus do not exist in SEGW project yet, so now we have to create them manually. Just create them from context menu by clicking Entity Types and Entity Sets in SEGW:
Create properties for entity type:
And assign entity type to newly created entity set. After that regenerate runtime artifacts.
3.3 Since now framework knows it should display the value of order_status_text to render the drop down list, so we are responsible to provide framework with correct content. Redefine method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET of your DPC_EXT:
METHOD /iwbep/if_mgw_appl_srv_runtime~get_entityset.
CASE iv_entity_name.
WHEN 'OrderStatus'.
get_Status_list( IMPORTING er_entityset = er_entityset ).
WHEN OTHERS.
TRY.
CALL METHOD super->/iwbep/if_mgw_appl_srv_runtime~get_entityset
EXPORTING
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
it_filter_select_options = it_filter_select_options
it_order = it_order
is_paging = is_paging
it_navigation_path = it_navigation_path
it_key_tab = it_key_tab
iv_filter_string = iv_filter_string
iv_search_string = iv_search_string
io_tech_request_context = io_tech_request_context
IMPORTING
er_entityset = er_entityset
es_response_context = es_response_context.
CATCH /iwbep/cx_mgw_busi_exception .
CATCH /iwbep/cx_mgw_tech_exception .
ENDTRY.
IF iv_entity_name = 'Z_C_OrderType'.
fill_status_text( CHANGING cr_entityset = er_entityset ).
ENDIF.
ENDCASE.
ENDMETHOD.
The method fill_status_text is responsible for filling the field order_status_text.
Note: if you comment out the line 40 and 46,
The annotation for order_status_text will become “standard”, instead of previous “fixed-values”.
In this case, this field will be rendered as F4 value help instead:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
相关推荐
系统和应用程序在运行过程中,为了提高运行速度或保存工作状态,会创建临时文件。例如,当一个程序崩溃时,系统可能会保存崩溃前的数据到临时文件,以便后续恢复;浏览器在浏览网页时,会缓存图片和页面部分内容,...
SAP Fiori Elements Development UX 403 SAP Fiori Elements Development UX 403 是一门关于 SAP Fiori 元素开发的高级课程,旨在帮助开发人员学习如何构建高质量的用户体验(UX)。本课程的主要目标是让开发人员...
SAP Fiori配置手册 本配置手册旨在指导用户完成SAP Fiori的设置和配置,从而实现SAP Fiori Launchpad的激活。下面是该手册中所涉及到的知识点: 1. 创建管理员账号和测试账号 在SAP Fiori的配置中,需要创建管理...
### SAP Fiori 快速指南知识点详述 #### 一、SAP Fiori 简介 SAP Fiori 是一款由 SAP 开发的新用户体验(UX),旨在为用户提供直观、简洁的操作界面。它包含了300多个基于角色的应用程序,覆盖了人力资源、制造、...
SAP fiori的简易开发过程指南,从开发者角度出发,分后面ODATA开发环境和前端SAP UI5环境搭建,以及发布进行了讲解
### SAP Fiori 2.0 开发指南 #### 概述 SAP Fiori 2.0 是 SAP 针对用户体验的一项重大升级,旨在提供更直观、更现代且更一致的用户界面。该版本引入了许多新功能和改进,不仅提高了用户满意度,还简化了系统管理员...
SAPUI5是一个前端JavaScript库,用于开发基于网页的应用程序,它支持响应式设计,并且与Fiori的用户体验准则一致。开发者需要设计出清晰直观的用户界面,并确保与OData服务的交互良好。 第五步,集成工作流。将设计...
### SAP Fiori APP 应用快速实施解决办法 #### 一、引言 SAP Fiori 是一种全新的用户界面设计原则和技术框架,旨在为用户提供直观、简洁和一致的体验。本文档将详细介绍如何通过手动配置步骤或使用预定义任务列表...
【SAP Fiori 现金流案例详解】 SAP Fiori 是一款由SAP公司开发的现代化用户体验设计框架,它提供了丰富的用户界面,旨在优化业务流程并提升工作效率。在这个最新的现金流案例中,我们看到SAP Fiori如何帮助用户实时...
SAP Fiori SAP Fiori SAP Fiori Architecture Architecture Overview to Deep Overview to Deep Dive -with with focus on S/4 HANA focus on S/4 HANA
SAP Fiori是一种创新的用户界面(UI)设计和交付架构,由SAP公司推出,旨在为企业应用程序带来消费级用户体验。SAP Fiori的目标是通过更新最广泛和频繁使用的SAP软件功能的用户界面,为用户提供即时价值,这些功能可以...
- 对于基于SAP NetWeaver 7.40的前端服务器,Fiori Launchpad和Launchpad Designer作为SAP_UI软件组件的一部分已经包含在标准SAP NetWeaver 7.40中。 - 对于基于SAP NetWeaver 7.31的前端服务器,Fiori Launchpad和...
- **创建新应用 (NEW)**:开发全新的应用,并遵循 SAP Fiori 的设计原则。 #### 6. SAP Fiori UX 概念 SAP Fiori UX 的核心概念包括: - **角色驱动**:根据用户的角色定制界面和功能。 - **简单性**:提供简洁...
### SAP Fiori 2.0 产品介绍 #### 一、设计原则与创新方法论 **SAP Fiori 2.0** 是SAP SE在2016年推出的一款面向用户需求的企业软件解决方案,其核心设计理念是为用户提供简单、一致且令人愉悦的用户体验。在**第...
因此,SAP 决定优化最常用的应用,创建了 SAP Fiori,以提供更简洁、更人性化的用户体验。 通过 SAP Fiori,企业不仅可以提升员工的工作效率,还能改善整体业务流程,提高用户满意度。随着技术的不断发展,SAP ...
此外,SAP Fiori还支持SAP Web Dynpro,这是一个基于Web的应用开发技术平台,让上手SAP技术变得更加容易,而且Web Dynpro提供了一个丰富的数据交互能力。 总结来说,SAP Fiori结合SAPUI5框架为用户提供了全新的体验...
SAP Fiori是一个为SAP软件用户界面提供全新设计框架的用户体验。它强调简洁直观的用户界面,并能够适应不同的设备,包括桌面电脑、平板和智能手机。SAP Fiori 2.0系列视频教程涵盖了从基础到高级的内容,帮助开发者...
SAP Fiori 快速启动板使用指南 SAP Fiori 快速启动板是 SAP Fiori 应用的外壳,为应用提供导航、个性化、嵌入支持和应用程序配置等服务。它是 SAP Fiori 应用在移动和桌面设备上的入口点。 快速启动板的组成部分 ...