`
JerryWang_SAP
  • 浏览: 1049842 次
  • 性别: Icon_minigender_1
  • 来自: 成都
文章分类
社区版块
存档分类
最新评论

SAP CDS view自学教程之八:SAP Fiori Elements里不同类型的annotation

阅读更多

During my recent CDS view explore I have experienced several ways of CDS view annotation declaration or generation. I list them in this blog for study purpose.

Approach 1: developer does not declaration explicitly, but backend generates automatically

Take this field for example:

 

 

I do not declare any display format on this field. It has DATS data type in the backend.

 

 

When you publish this CDS view as OData service and check its metadata response, you can find the annotation “sap:display-format=Date” is automatically added. Who adds it?

 

 

Answer: it is added here. Backend framework will automatically add corresponding annotation according to the data type of exposed field.

 

 

Approach 2: developer adds one style of annotation, and backend framework detects such annotation, and do some conversion

One example of this kind of approach can already be found from tutorial 7 – unveil the secret of @ObjectModel.readOnly

In that tutorial I explained how the annotation defined by developer (@ObjectModel.readOnly: true ) is converted by backend framework into sap:updatable = false.

@ObjectModel.readOnly: true Z_i_Order_View.posting_date We can also look into another example. We have use the following annotation “@Consumption.valueHelp: ‘_statusfixedvalue’ ” to assign a value help to field txt04: @Consumption.valueHelp: ‘_statusfixedvalue’ Z_i_Order_View.txt04, When framework has scanned the annotation in line 47, it will set flag lv_consumption_vh as true.

 

 

Base on the fact whether the assigned value help is a consumption or foreign key value help, different element name are put to internal table lt_param_display and finally all the left annotation necessary for value help is generated by framework:

 

 

And this picture below explains where does each field in metadata response come from. The logic in method _add_value_help is very useful as it teaches us how to create necessary annotation via ABAP code, which we will use later.

 

 

Approach 3: developer adds necessary annotation via ABAP code

If you would like to build a drop down list based on a CDS view field like the status field below,

 

 

it is not just enough to use the annotation “Consumption.valueHelp” in CDS view source code – you would just get a drop down list with technical code of status value displayed. Instead, you must tell Smart template framework to display status description text in drop down list.

 

 

In order to archieve it, you must add the following ABAP code in DEFINE method of the MPC_EXT class of your OData service, to tell the framework that the text property for “status_code” is “status_text” by annotation. The usage of such coding to create annotation by ABAP code is learned from method _add_value_help mentioned in approach 2.

lo_txt_property = model->get_entity_type( 'Z_C_Status_FixedvalueType' )->get_property( 'status_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 = 'status_text').

For details please refer to this blog How to build a drop down list using Smart template + CDS view

Approach 4: developer adds UI related annotation in CDS view which are consumed by UI5 SmartTemplate

All UI related annotation which could be inserted into CDS view source code could be found from SAP help.

Those UI annotations will not be converted by ABAP backend:

@UI.identification: [ { position: 10 } ]
Z_i_Order_View.posting_date

All UI related annotations could be retrieved via the url below:

 

 

And in the runtime, Smart-template also uses this very url to retrieve UI annotations so that it can know what styles of UI control the annotated CDS view field must be rendered as.

 

 

Conclusion

For approach 1 & 2, they sometimes look mysterious as everything happens under the hood. Fortunately we are in ABAP world and we can debug everything to clarify what confuses us by ourselves

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

0
0
分享到:
评论

相关推荐

    SAP Fiori Elements Development UX 403

    SAP Fiori Elements Development UX 403 是一门关于 SAP Fiori 元素开发的高级课程,旨在帮助开发人员学习如何构建高质量的用户体验(UX)。本课程的主要目标是让开发人员掌握 SAP Fiori 元素开发的技能,并了解如何...

    SAP企业自开发指南:ABAP、Fiori、CDS视图与接口开发技术详解

    主要包括ABAP编程、Fiori应用开发、CDS视图开发、接口开发以及数据库脚本开发等方面的内容。每个部分都列举了具体的开发任务及其相应的开发工具,并强调了测试和部署的重要性。 适合人群:具有SAP相关背景的开发人员...

    SAP Fiori_Training_Day_3.pdf

    Session 1: Introduction to FIORI Elements (30 mins) • Hands on 1: Build a FIORI Elements application (60 mins) • Session 2: Enhance FIORI Elements Application (30 mins) • Hands on 2: FIORI Elements...

    SAP Fiori_Training_Day_2.pdf

    SAP ODATA Training Agenda • Session 1: Introduction to SAPUI5 / FIORI (40 mins) ▫ Basic MVC concept: Model, View, Controller ▫ UI5 Control libraries • Session 2: Introduction to SAP Web IDE (20 ...

    SAP S4HANA Fiori配置

    在企业信息化管理领域,SAP S/4HANA是一款先进的企业资源规划系统,它结合了现代化的用户体验设计,也就是Fiori,为用户提供简洁、直观的交互界面。本篇文章将详细探讨SAP S/4HANA Fiori的配置过程以及简单的权限...

    sapFiori配置手册[整理].pdf

    SAP Fiori配置手册 本配置手册旨在指导用户完成SAP Fiori的设置和配置,从而实现SAP Fiori Launchpad的激活。下面是该手册中所涉及到的知识点: 1. 创建管理员账号和测试账号 在SAP Fiori的配置中,需要创建管理...

    ERP软件:SAP二次开发-ABAP编程基础+ERP软件:SAP二次开发-SAP Fiori开发

    ERP软件:SAP二次开发_SAP Fiori开发.docx ERP软件:SAP二次开发_SAP HANA集成开发.docx ERP软件:SAP二次开发_SAPWebDynpro开发.docx ERP软件:SAP二次开发_SAP二次开发中的数据管理.docx ERP软件:SAP二次开发_SAP...

    SAP-Fiori---快速指南.docx

    SAP Fiori 快速指南 SAP Fiori 是 SAP 软件和应用程序的新用户体验(UX),提供了一组应用程序,用于常规业务功能,如工作批准,金融...3. 提高灵活性:SAP Fiori 支持多个设备应用程序,允许用户在不同的设备上使用。

    SAP Fiori---快速指南 共82页 2018年编著 word文档

    ### SAP Fiori 快速指南知识点详述 #### 一、SAP Fiori 简介 SAP Fiori 是一款由 SAP 开发的新用户体验(UX),旨在为用户提供直观、简洁的操作界面。它包含了300多个基于角色的应用程序,覆盖了人力资源、制造、...

    SAP-Fiori-快速指南

    这个快速指南将带你了解 SAP Fiori 的基本概念、设计原则以及不同类型的 SAP Fiori 应用程序。 首先,SAP Fiori 的核心在于提供一组基于角色的应用程序,覆盖了各种业务场景,比如人力资源、制造和财务等。这些应用...

    SAP Fiori 2.0开发指南

    ### SAP Fiori 2.0 开发指南 #### 概述 SAP Fiori 2.0 是 SAP 针对用户体验的一项重大升级,旨在提供更直观、更现代且更一致的用户界面。该版本引入了许多新功能和改进,不仅提高了用户满意度,还简化了系统管理员...

    SAP Fiori开发视频教程--由浅入深学习Fiori开发

    本课程将由浅入深,从后端到前端,从较早的Eclipse开发到现在流行的WebIDE开发,从SAPUI5到ABAP 再到CDS, 从简单的List APP到较为复杂的Fiori Element开发,系统性地讲述SAP Fiori的开发过程。学员学习本套课程后,...

    SAP Fiori Launchpad配置指南

    ### SAP Fiori Launchpad配置指南 #### 一、引言 SAP Fiori Launchpad作为移动和桌面设备上的Fiori应用程序入口,为用户提供了一种直观便捷的方式去访问各种业务流程相关的应用。为了确保Fiori Launchpad能够满足...

    SAP Fiori 学习概要

    SAP Fiori 2.0系列视频教程涵盖了从基础到高级的内容,帮助开发者了解和掌握SAP Fiori的各项技术要点。 教程的第一部分介绍了SAP Fiori的基本概念,包括其简介、运行环境、核心技术框架、开发技术要求以及开发工具...

    SAP Fiori APP 应用快速实施解决办法

    SAP Fiori 支持三种不同类型的应用程序: 1. **交易应用程序**:这类应用程序通常用于执行事务性任务,如创建请假请求等,能够在SAP HANA数据库上获得最佳性能。 2. **分析应用程序**:用于收集和展示基于角色的...

    SAP Fiori overview

    自2013年发布以来,SAP Fiori 已经成为了 SAP 软件产品中的核心元素之一,旨在通过简洁、直观的设计提升用户的操作体验。 #### 描述:SAP Fiori UX 概览 2015/03 该文档提供了 SAP Fiori 用户体验在2015年3月时的...

    Building SAP Fiori-like UIs with SAPUI5 in 10 Exercises

    这些练习需要SAPUI5运行时版本1.16.4,这个版本包括在多个SAP平台发布版本中,比如SAP NetWeaver AS ABAP 7.0/7.01/7.02/7.03/7.31、SAP NetWeaver AS ABAP 7.40 SPS 6、SAP NetWeaver AS Java 7.31 SPS 10、SAP ...

    SAP Fiori用户界面与应用开发指南

    ②掌握SAP Fiori不同应用程序类型的部署和配置方法;③熟悉SAP Fiori的安全机制和数据流动流程。 其他说明:SAP Fiori基于SAP HANA数据库和UI5技术构建,旨在提供高效、实时、角色化的企业级业务应用程序。此外,SAP...

    10Steps2S4: Gateway and Fiori Configuration

    ERP升级至S4HANA 第八步: Gateway and Fiori Configuration

Global site tag (gtag.js) - Google Analytics