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:
  • DCL:

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 注解的更多相关文章

  1. HANA CDS与ABAP CDS

    如果你在网络或者SCN上面搜索CDS,即SAP的Core Data Services,你会很容易地找到类似“Core Data Services(CDS)是一个在SAP HANA中用于定义和消费富语义 ...

  2. 教程:基于访问控制的ABAP CDS视图权限

    Hi! 对每一个CDS视图,我们都可以通过DCL(Data Control Language)定义访问控制.在这篇文章中,我会介绍ABAP CDS视图中非常重要的一面:权限管理. 本文的阐述基于我正在 ...

  3. ABAP CDS Table Function介绍与示例

    Core data services(以下简称CDS)可以指两样东西,一个是HANA CDS,一个是ABAP CDS. 如我们所知,HANA CDS只支持HANA数据库,ABAP CDS理论上支持多种 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. ABAP CDS - DEFINE VIEW, view_annot

    Syntax ... @annotation ... Effect Specifies Annotation annotation in the definition of a CDS view of ...

  8. ABAP CDS - Language Elements

    The following sections summarize the language elements of the DDL and DCL of the ABAP CDS, arranged ...

  9. Android注解使用之使用Support Annotations注解优化代码

    前言: 前面学习总结了Java注解的使用,博客地址详见Java学习之注解Annotation实现原理,从本质上了解到什么注解,以及注解怎么使用?不要看见使用注解就想到反射会影响性能之类,今天我们就来学 ...

随机推荐

  1. JavaWeb项目端口占用问题

    今天使用springboot编写项目的时候安装了一个插件,重启了idea,但是项目忘记终止连接了,再打开idea启动项目发现端口被占用 控制台输出: ************************* ...

  2. SpringMVC踩坑3——前后端传值问题

    在前端页面点击修改,同时把需要修改的ID传到后端,后端根据ID去修改具体数据 这是前端代码 <a href="${pageContext.request.contextPath}/bo ...

  3. 2021.12.15 P2328 [SCOI2005]超级格雷码(找规律填空)

    2021.12.15 P2328 [SCOI2005]超级格雷码(找规律填空) https://www.luogu.com.cn/problem/P2328 题意: 输出n位B进制的格雷码. 分析: ...

  4. PostgreSQL培训认证讲师招募

    中国PostgreSQL考试认证中心 以"知"之名,携手共进!不蒂于知识共享,技术传承,更愿为讲师耕织嫁衣,助您成为PostgreSQL圈的意见领袖,用知识改变世界! 一.入选讲师 ...

  5. 痞子衡嵌入式:聊聊系统看门狗WDOG1在i.MXRT1xxx系统启动中的应用及影响

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是系统看门狗WDOG1在i.MXRT1xxx系统启动中的应用及影响. 软件看门狗模块(WDOG)在 MCU 应用里可以说是非常基础的功能模 ...

  6. 【第六课】SHELL和计划任务(学习笔记)

    4月15日学习笔记

  7. PDCA循环——快速提升软件质量的必备工具

    近年来,软件项目的规模及其复杂性正在以空前的速度增长,互联网用户市场庞大,互联网公司和相应的软件产品层出不穷.快速响应需求变化往往是互联网行业的常态,软件产品的快速开发迭代对于公司迅速占领市场.抢占商 ...

  8. 测试必会 Docker 实战(一):掌握高频命令,夯实内功基础

    在 Dokcer 横空出世之前,应用打包一直是大部分研发团队的痛点.在工作中,面对多种服务,多个服务器,以及多种环境,如果还继续用传统的方式打包部署,会浪费大量时间精力. 在 Docker 出现后,它 ...

  9. 实战 | Linux根分区扩容

    一个执着于技术的公众号 一个执着于技术的公众号 前言 Linux系统作为服务器操作系统,经常遇到一个问题就是服务器分区磁盘空间不足需要扩容的情况.本文以linux系统最常见的发行版centos7系统为 ...

  10. SSH只能用于远程Linux主机?那说明你见识太小了!

    开源Linux 长按二维码加关注~ 今天小编为大家分享一篇关于SSH 的介绍和使用方法的文章.本文从SSH是什么出发,讲述了SSH的基本用法,之后在远程登录.端口转发等多种场景下进行独立的讲述,希望能 ...