ABAP CDS - Annotations 注解
Syntax
... annotation[.annotation1[.annotation2]][:value] ...
Effect
Annotation that can be specified at predefined positions within a CDS source code, to enhance a definition of the ABAP CDS with meta data. An annotation consists of a single or multiple-part name and an optional specified value.
Names
An annotation has a single-part name
- ... annotation ...
or a multiple-part name
- ... annotation.annotation1.annotation2...,
in which single names are separated by a period . (full stop). The individual names annotation, annotation1, annotation2, ... can contain letters, digits, and underscores and must start with a letter. The name of an annotation must be unique in the context of the annotation.
- A set of predefined annotations with predefined names is available; these can be specified for specific contexts of a definition, expect specific values, and can be analyzed by the runtime environment. These annotations are documented for the respective context.
- All other names define self-defined annotations, to which any value can be assigned and which must be analyzed by the application itself.
Specified Value
A value value can be specified after a colon :. However, an annotation does not have to contain a value. The following can be specified for value:
- Literals
- Character literals or numeric literals embedded in inverted commas
- Truth values true and false
- These values can be embedded in inverted commas optionally.
- Enumeration values #value
- Specific predefined annotations expect preset values; these are specified directly and without inverted commas after the # character.
- Value lists [ value1, value2, ...]
- Comma-separated lists of values can be specified in square brackets; for such values, the same applies as for value. This is used for structuring an annotation, by assigning different values to it. Direct nesting of square brackets is syntactically possible; however, this is currently ignored during the analysis of the annotations.
- Annotation lists { annotation1[:value1], annotation2[:value2], ...}
- Curly brackets can be used to specify comma-separated lists of annotations. The internal annotations have the same syntax as the external annotation. Specifying an annotation list after an annotation produces a nested annotation and has the same effect as specifying individual names as follows:
- annotation.annotation1[:value1]
annotation.annotation2[:value2]
...
Evaluation
The evaluation of annotations differs between predefined and self-defined annotations:
- Predefined annotations with predefined names specify the technical and semantic properties of CDS objects that are analyzed by the runtime environment.
- Self-defined annotations with self-defined names must be analyzed by the application itself using a suitable API. Currently, no global API for analyzing self-defined annotations is supplied. Instead, a direct access to the database tables containing the meta data is possible.
Contexts for Annotations
Annotations can be specified for the following contexts.
- DDL:
- Annotations for a CDS view in front of the statement DEFINE VIEW.
- Annotations for an element of a SELECT list of a CDS view in front of or after the element.
- Annotations for a CDS view in front of the statement EXTEND VIEW.
- DCL:
- Annotations for a CDS role in front of the statement DEFINE ROLE.
- Annotations for an aspect in an access policy in front of the statement DEFINE ASPECT.
The predefined annotations that are possible for a context are documented here.
Example
The following CDS source code for defining a CDS view contains predefined and self-defined annotations at the allowed positions, that is for the entire view and for an element of the SELECT list. The predefined annotations include AbapCatalog.sqlViewName and ClientDependent for the entire view, and EndUserText.label and EndUserText.quickInfo for the element of the SELECT list. The remaining annotations are self-defined.
- @AbapCatalog.sqlViewName: 'DEMO_VIEW_ANNOT'
@ClientDependent: false
@v_annot0
@v_annot1:'abc'
@v_annot2:123
@v_annot3:[ 'abc', 123 ]
@v_annot4:{ annot0, annot1:'abc', annot2:123 }
@v_annot5.annot0
@v_annot5.annot1:'abc'
@v_annot5.annot2:123
@v_annot6:[ 'abc', 123,
[ 'abc', 123 ],
{ annot0, annot1:'abc', annot2:123 } ]
@v_annot7:{ annot0,
annot1:[ 'abc', 123 ],
annot2:{ annot0, annot1:'abc', annot2:123 } }
define view demo_cds_view_annotations
as select from demo_expressions
{ @f_annot0
key id as key_field
@<f_annot1:'abc'
@<f_annot2:123,
@EndUserText:{ label:'Some field', quickInfo:'Some info' }
@f_annot1:[ 'abc', 123 ]
num1 as some_field
@<f_annot2:{ annot0, annot1:'abc', annot2:123 }
}
The program DEMO_CDS_DDL_ANNOTATIONS accesses the corresponding meta data in database tables DDHEADANNO and DDFIELDANNO and displays these. It should be noted that the notations for v_annot4 and v_annot5 are the same, and that the nested square bracket in the annotation v_annot6 is ignored. Compared with the table for the entire view, the table for the SELECT list additionally contains the name of the element for which an annotation was created.
ABAP CDS - Annotations 注解的更多相关文章
- HANA CDS与ABAP CDS
如果你在网络或者SCN上面搜索CDS,即SAP的Core Data Services,你会很容易地找到类似“Core Data Services(CDS)是一个在SAP HANA中用于定义和消费富语义 ...
- 教程:基于访问控制的ABAP CDS视图权限
Hi! 对每一个CDS视图,我们都可以通过DCL(Data Control Language)定义访问控制.在这篇文章中,我会介绍ABAP CDS视图中非常重要的一面:权限管理. 本文的阐述基于我正在 ...
- ABAP CDS Table Function介绍与示例
Core data services(以下简称CDS)可以指两样东西,一个是HANA CDS,一个是ABAP CDS. 如我们所知,HANA CDS只支持HANA数据库,ABAP CDS理论上支持多种 ...
- Create Fiori List App Report with ABAP CDS view – PART 2
In the Part 1 blog, we have discussed below topics CDS annotations for Fiori List Report. How to cre ...
- Create Fiori List App Report with ABAP CDS view – PART 1
From Create Fiori List App Report with ABAP CDS view – PART 1 In this blog, I am going to show How C ...
- ABAP CDS - Syntax
The syntax of the DDL and of the DCL of the ABAP CDS comprises elements of the general DDL and DCL o ...
- ABAP CDS - DEFINE VIEW, view_annot
Syntax ... @annotation ... Effect Specifies Annotation annotation in the definition of a CDS view of ...
- ABAP CDS - Language Elements
The following sections summarize the language elements of the DDL and DCL of the ABAP CDS, arranged ...
- Android注解使用之使用Support Annotations注解优化代码
前言: 前面学习总结了Java注解的使用,博客地址详见Java学习之注解Annotation实现原理,从本质上了解到什么注解,以及注解怎么使用?不要看见使用注解就想到反射会影响性能之类,今天我们就来学 ...
随机推荐
- node服务器搭建流程
1,创建一个空文件夹,用来存放项目. 2,在空文件夹中,在cmd命令提示符中输入npm init 初始化一个服务器项目. 设置的属性信息: name : 项目名称(小括号中是默认的,文件夹名相 ...
- gin框架使用【2.RESTFUL API使用】
package mainimport ( "github.com/gin-gonic/gin")func main() { router := gin.Default() rout ...
- Book2Notion:将豆瓣图书信息同步到Notion的Chrome插件
背景 前几天写了一个python脚本从豆瓣爬数据然后保存到Notion,被身边同学吐槽使用起来太麻烦,而且也不是所有人都会Python(原话是充满了码农版"何不食肉糜").正好最近 ...
- Objective-C 基础教程第九章,内存管理
目录 Object-C 基础教程第九章,内存管理 前言: 对象生命周期 引用计数 RetainCount1项目例子 对象所有权 访问方法中的保留和释放 自动释放 所有对象放入池中 自动释放池的销毁时间 ...
- 在 K8s 上运行 GraphScope
本文将详细介绍:1) 如何基于 Kubernetes 集群部署 GraphScope ; 2) 背后的工作细节; 3) 如何在分布式环境中使用自己构建的 GraphScope 开发镜像. 上篇文章介绍 ...
- 【MQ】java 从零开始实现消息队列 mq-02-如何实现生产者调用消费者?
前景回顾 上一节我们学习了如何实现基于 netty 客服端和服务端的启动. [mq]从零开始实现 mq-01-生产者.消费者启动 [mq]java 从零开始实现消息队列 mq-02-如何实现生产者调用 ...
- vue动态路由实现原理 addRoute
vue新版router.addRoute基础用法 新版Vue Router中用router.addRoute来替代原有的router.addRoutes来动态添加路由.子路由 在添加子路由的时候 比如 ...
- Go单体服务开发最佳实践
单体最佳实践的由来 对于很多初创公司来说,业务的早期我们更应该关注于业务价值的交付,并且此时用户体量也很小,QPS 也非常低,我们应该使用更简单的技术架构来加速业务价值的交付,此时单体的优势就体现出来 ...
- Flume 详解&实战
Flume 1. 概述 Flume是一个高可用,高可靠,分布式的海量日志采集.聚合和传输的系统.Flume基于流式架构,灵活简单. Flume的作用 Flume最主要的作用就是,实时读取服务器本地磁盘 ...
- 1.3 Linux和UNIX的关系及区别(详解版)
UNIX 与 Linux 之间的关系是一个很有意思的话题.在目前主流的服务器端操作系统中,UNIX 诞生于 20 世纪 60 年代末,Windows 诞生于 20 世纪 80 年代中期,Linux 诞 ...