Ansicht
Dokumentation
ABENCDS_F1_DEFINE_ANNO_ANNOS - CDS F1 DEFINE ANNO ANNOS
RFUMSV00 - Advance Return for Tax on Sales/Purchases RFUMSV00 - Advance Return for Tax on Sales/PurchasesThis documentation is copyright by SAP AG.
- DEFINE ANNOTATION, annotation_annot
... @annotation ...
Effect
Specifies an annotation annotation as an annotation definition annotation in front of the statement DEFINE ANNOTATION or in front of a subannotation in an annotation definition in ABAP CDS. The character @ must be placed in front of the name annotation of the annotation. The annotation must be defined as a CDS object in a CDS annotation definition and the annotation definition annotation @Scope must be specified here using the value #ANNOTATION.
The annotations of an annotation definition can be specified in front of the name of the main annotation and in front of the names of subannotations. If an annotation is not specified directly in front of a subannotation, it is inherited by the next higher annotation in the hierarchy.
The following tables show the possible ABAP annotations that can be specified and their meanings. Annotations with other identifiers are usually framework-specific annotations. These are not evaluated by the ABAP runtime framework but by other SAP frameworks instead.
AbapAnnotation Annotations
Specify how the annotation can be used.
AbapAnnotation.definitionHidden,,Hidden
annotation,,true:\lbr The annotation
is used for tests and demonstrations. It is not detected using source code color and or by Code Completion
and cannot be used in production CDS source code \lbr\lbr
false:\lbr Public annotation for use in production CDS source code,,false,,true
API Annotations
Specify the visibility for an released API.
API.state[ ],,Defines for which ABAP language version the annotation is
released as an
API.,,#RELEASED_FOR_SAP_CLOUD_PLATFORM:\lbr The annotation is released for ABAP language version
. \lbr\lbr
#RELEASED_FOR_KEY_USER_APPS:\lbr The annotation is released for ABAP language version
. \lbr\lbr
#NOT_RELEASED:\lbr The annotation is not released as an API. ,,#NOT_RELEASED,,-
CompatibilityContract Annotations
Define the usability of the annotation in CDS entities with a certain release contract.
CompatibilityContract.rc.usageAllowed,,Defines
the usability in CDS entities with release contract
rc.,,
true:\lbr The annotation can be used \lbr\lbr
false:\lbr The annotation cannot be used,,false,,true
CompatibilityContract.rc.allowedChanges.annotation[
],,Defines whether the annotation can be added or removed in a CDS entity with release contract
rc
after its release,,#ANY:\lbr The annotation
can be added and removed \lbr\lbr #ADD:\lbr
The annotation can be added but not removed \lbr\lbr
#REMOVE:\lbr The annotation can be removed but not added \lbr\lbr
#NONE:\lbr The annotation cannot be added or removed \lbr\lbr
#CUSTOM:\lbr The way the annotation can be modified is defined and checked specific to the framework
in question,,-,,-
CompatibilityContract.rc.allowedChanges.value[ ],,Defines whether the
annotation
values can be modified in a CDS entity with release contract
rc after its release,,
#ANY:\lbr All annotation values can be changed as required \lbr\lbr
#UPDATE:\lbr Specific annotation values can be changed as required \lbr\lbr
#FALSE_TO_TRUE:\lbr Specific truth values can be changed from
false to true. \lbr\lbr
#TRUE_TO_FALSE:\lbr Specific truth values can be changed from
true to false. \lbr\lbr #ADD:\lbr Annotation values can be added to
annotation
arrays but not removed \lbr\lbr #REMOVE:\lbr Annotation values can be removed from
annotation
arrays but not added \lbr\lbr #NONE:\lbr
Annotation values cannot be modified \lbr\lbr #CUSTOM:\lbr
The way the annotation values can be modified is defined and checked specific to the framework in question,,
-,,-
Here, the subannotation rc specifies a release contract in the annotation syntax. The following can be specified:
- c0
- The C0 contract allows extension fields to be added at specific extension points.
- c1
- The C1 contract guarantees a stable interface for use within AS ABAP.
- c2
- The C2 contract guarantees a stable interface for uses outside AS ABAP too.
In annotation definitions delivered by SAP, the annotations @CompatibilityContract must be specified for the release contract C1 and C2, both for the main annotation and for every subannotation. They define the usability of the main annotations and subannotations in the CDS source code of a CDS entity with respect to their release contract. A CDS entity is mapped to a release contract using tools such as ADT or in special transactions, and not in its CDS source code.
Note
When specified, the annotation @CompatibilityContract can be governed by framework-specific conditions, such as the features of analytic frameworks that consume CDS views. SAP reserves the right to modify @CompatibilityContract if these framework-specific conditions change.
Example
Example of the use of the annotation @CompatibilityContract in an annotation definition. The annotation that follows can be used in CDS entities with the release contract c1. Here, it can added and removed even after the release of a CDS entity and the annotation values can be modified. It cannot be used in CDS entities with the release contract c0 and c2.
@CompatibilityContract: {
c0: { usageAllowed: false },
c1: { usageAllowed: true,
allowedChanges.annotation: [ #ANY ],
allowedChanges.value: [ #ANY ] },
c2: { usageAllowed: false } }
LanguageDependency Annotations
Define the translatability of texts with the type String.
LanguageDependency.maxLength,,Specifies that the
annotation
value is a translatable text.,,The maximum usable length of the text. The recommended length is determined by the length determined in the
type. No values greater
than the recommended value can be specified.,,-,,-
Notes
- The annotation LanguageDependency.maxLength can only be specified for annotations of String with lengths between 10 and 255. This means that it can usually only be used directly in front of subannotations of this type.
MetadataExtension Annotations
Specify how annotations are moved to CDS metadata extensions.
MetadataExtension.usageAllowed,,Specifies
whether the annotation can be specified in a metadata extension when the statement
ANNOTATE is used.,,true:\lbr
The annotation can be specified in a metadata extension \lbr\lbr
false:\lbr The annotation cannot be specified in a metadata extension,,false,,true
Note
Alongside @MetadataExtension.usageAllowed:true, the scope specified using the annotation @Scope determines where the annotation can be specified in a metadata extension. The scope must match the annotation and metadata extensions must be allowed for this scope.
Scope Annotations
Define the scope of the annotation.
Scope[ ],,Defines the
scope of the annotation.,,
#ACCESSPOLICY:\lbr CDS access policy \lbr\lbr
#ANNOTATE:\lbr CDS metadata extension \lbr\lbr
#ANNOTATION:\lbr CDS annotation \lbr\lbr#ASPECT:\lbr
not yet documented \lbr\lbr#ELEMENT:\lbr
Element \lbr\lbr#ENTITY:\lbr any CDS
\lbr\lbr#EXTEND_VIEW:\lbr CDS view extension
\lbr\lbr#PARAMETER:\lbr Parameter \lbr\lbr
#PFCG_MAPPING:\lbr PFCG mapping \lbr\lbr#ROLE:\lbr
CDS role \lbr\lbr#SERVICE:\lbr CDS service
definition \lbr\lbr#SIMPLE_TYPE:\lbr
currently not used \lbr\lbr#TABLE_FUNCTION:\lbr
CDS table function \lbr\lbr#VIEW:\lbr
CDS view (view entity, projection view, DDIC-based view),,-,,- The
scope of each annotation must
be defined using @Scope. It determines the places in CDS source code where the annotation can be
specified. @Scope is an
annotation array, which means that multiple
annotation
values can be specified in square brackets. If no scope can be determined for an annotation or subannotation, a syntax error occurs.
Note
While the annotation value #ENTITY defines that an annotation can be specified in the definition of any CDS entity, this is not the case for the annotation value #VIEW. The annotation value #VIEW defines that an annotation can be specified in the definition of one of the possible kinds of CDS views (view entity, projection view, DDIC-based view) but it does not define exactly where. There is a special a set of ABAP annotations that can be used in DDIC-based views only. The ABAP annotations that can be specified for a kind of view are documented for the respective DEFINE statement. For an overview see ABAP Annotation Syntax.
Addresses (Business Address Services) General Material Data
This documentation is copyright by SAP AG.
Length: 20191 Date: 20240423 Time: 153034 sap01-206 ( 227 ms )