Get Example source ABAP code based on a different SAP table
C0 Contract Rules for Consumers of CDS Entities The provider rules> for objects with the C0 contract ensure that released objects are changed only in a very restricted way and help to avoid errors and interruptions after an SAP upgrade. Nevertheless, the rules do not prescribe full downward compatibility and leave some room for necessary enhancements to released APIs>. Therefore, users of released APIs still have to consider the allowed compatible changes and access the APIs in such a way that the following errors and interruptions are avoided:
Problems during an upgrade.
Syntax errors after an upgrade.
Runtime errors after an upgrade.
Wrong behavior after an upgrade. The following sections list allowed extensions to released APIs that must be considered when creating an extension. ITOC
Naming Rules
The alias name for elements and associations must start with the correct namespace prefix>. For customers and partners, this means that either ZZ> or YY> must be used as prefix. For associations, it is strongly recommended that the alias name starts with an underscore (_) followed by the correct namespace prefix.
All elements and associations defined in the extension must have the element suffix that is defined in the released API by means of the annotation @AbapCatalog.extensibility.elementSuffix>>.
In extensions to CDS view entities> and CDS projection views>, all elements and associations defined in the extension must have the alias name of a stable data source, defined by the annotation @AbapCatalog.extensibility.dataSources>>, as prefix. Examples for correct names:
DatasourceAlias.field as ZZ_customerField_suffix>
DatasourceAlias._assoc as _YY_assoc_suffix>
General Rules
Currently, CDS view entities>, CDS projection views>, CDS abstract entities>, and CDS custom entities> can be extended.
The extended CDS entity must be released under the C0 contract for the corresponding language version (ABAP for Cloud Development> or ABAP for Key Users>).
The extension must fit the quota definition defined in the extended entity by means of the annotations AbapCatalog.extensibility.quota.maximumBytes>> and AbapCatalog.extensibility.quota.maximumFields>>. That means that the maximum number of fields and the maximum number of bytes must not be exceeded.
Rules for Extension Fields
To define an additional field for a C0 released API that is selected from another data source, the field must either belong to the same software component, or be C1 released.
To define additional fields for a released API, in a scenario where these additional fields are selected from another extension, both extensions must be assigned to the same software component or the extended entity must be C1 released.
Rules for Node Extension
Adding new child nodes to a released API by means of CDS compositions> is allowed if the annotation @AbapCatalog.extensibility.allowNewCompositions>> is set to true>.
Rules for Associations
Associations that are released with a stable alias name by the extended entity, using the annotation AbapCatalog.extensibility.dataSources > , must not be exposed in the element list.
To define a new association in an extension, the association target must be C1 released> or created in the same software component.
Newly defined, local associations can be exposed in the element list. The name of a newly defined, local association must comply with the naming rules described in section Naming>.
Rules for Path Expressions:
In an extension to a released API, exposed associations and associations used within path expressions can have a target cardinality> of 0 or 1. A target cardinality greater than 1 is not allowed.
Path traversing with the exact length of 1 is allowed for released data sources with stable alias names.
Path traversing with the exact length of 1 is not> allowed for locally defined associations.
Path traversing with a length greater than 1 is only allowed in the following cases:
The extended object must be a CDS projection view.
The annotation @AbapCatalog.extensibility.allowNewDatasources>> is set to true>.
All traversed objects of the path are CDS view entities or CDS DDIC-based views.
Examples for path lengths:
BaseObjectAlias.fieldName> //path length of 1
BaseObjectAlias._assoc.fieldName> //path length of 2
Restrictions
The following data types are not supported in extensions to released APIs: LCHR>>, LRAW> >, STRING>>, RAWSTRING>>, GEOM_EWKB>>.
Reusing expressions using $projection>> as pointer is not supported when extending a released API.
Session variables> are not supported when extending a released API.
The built-in function utcl_current>> is not supported in extensions to released APIs.
Example Topics Example for a C0 released CDS view entity which is extended from a restricted ABAP language version> Example for a C0 released CDS projection view which is extended from a restricted ABAP language version> Example for C0 node extensibility>