当定义 CDS View 时,可以使用以下注解来指定视图和实体属性、行为和 UI 元数据等方面的信息。这里列举一些常见的注解及其作用,持续更新记录一下:
全局级别的属性
- @OData.publish:true : 自动暴露CDSVIEW作为odata服务
字段级别的属性
@UI.hidden:true :隐藏
@ObjectModel.readOnly: ‘EXTERNAL_CALCULATION’ :内部计算,涉及到后台计算来决定的,需要加上这个
具体解释
-
@UI.headerInfo.typeNamePlural : determines text displayed for the list report
-
@UI.lineItem is used to set default columns for the list report. The mandatory property is position, which determines the sequence of columns. The label for each field comes from field label of data element for a field.
-
@UI.lineItem.label is used to assign a label if field label of data element is not available.
-
@semantics.currencyCode/@semantics.unitofMeasure : to annotate for currency/unit field.
-
@semantics.amount.currencyCode/@semantics.quantity.unitofMeasure : to annotate amount/quantity field and tell them which field has the information of currencyCode/ unitofMeasure
-
@UI.lineItem.importance to determine in which clients the field should display:
- HIGH: default value, display in all clients
- MEDIUM: Only display in desktop browser or tablet
- LOW: Only display in browser
-
@UI.hidden to hide fields that need not be exposed to end user
以上注解只是一部分,还有很多其他的注解可以用于 CDS View 的定义,具体取决于您的需求。如果您需要详细了解 CDS 注解,请参考 SAP 官方文档或者其他相关资源。