Pages

Saturday 7 December 2019

All about CDS Annotations

This blog would give insights about the Annotations used in the S4HANA CDS DDL views.

If you are begineer then you will be puzzeled what are the available Annotations which we can use while creating a CDS view. SAP doesn’t allow any customer specific annotations so you have to use what ever SAP delivered.

Below is the whole list available in English and sorted by Annotation group. Intentionally added in code format so that it would easy to copy

AbapCatalog.buffering.numberOfKeyFields
AbapCatalog.buffering.status
AbapCatalog.buffering.type
AbapCatalog.compiler.compareFilter
AbapCatalog.dbHints[ ].dbSystem
AbapCatalog.dbHints[ ].hint
AbapCatalog.preserveKey
AbapCatalog.sqlViewAppendName
AbapCatalog.sqlViewName
AbapCatalog.viewEnhancementCategory[ ]
AccessControl.authorizationCheck
ClientDependent
ClientHandling.algorithm
ClientHandling.type
Consumption.defaultValue
Consumption.derivation.binding[ ].targetElement
Consumption.derivation.binding[ ].targetParameter
Consumption.derivation.binding[ ].type
Consumption.derivation.binding[ ].value
Consumption.derivation.derivationFilter
Consumption.derivation.lookupEntity
Consumption.derivation.procedure
Consumption.derivation.resultElement
Consumption.filter.defaultValue
Consumption.filter.hidden
Consumption.filter.hierarchyBinding[ ].type
Consumption.filter.hierarchyBinding[ ].value
Consumption.filter.hierarchyBinding[ ].variableSequence
Consumption.filter.mandatory
Consumption.filter.multipleSelections
Consumption.filter.selectionType
Consumption.groupWithElement
Consumption.hidden
Consumption.labelElement
Consumption.quickInfoElement
Consumption.semanticObject
Consumption.valueHelp
DataAging.noAgingRestriction
EndUserText.label
EndUserText.quickInfo
Environment.sql.passValue
Environment.systemField
MappingRole
Metadata.allowExtensions
Metadata.ignorePropagatedAnnotations
Metadata.layer
OData.publish
ObjectModel.association.type[ ]
ObjectModel.compositionRoot
ObjectModel.createEnabled
ObjectModel.dataCategory
ObjectModel.deleteEnabled
ObjectModel.foreignKey.association
ObjectModel.mandatory
ObjectModel.modelCategory
ObjectModel.readOnly
ObjectModel.representativeKey
ObjectModel.semanticKey[ ]
ObjectModel.text.association
ObjectModel.text.element[ ]
ObjectModel.updateEnabled
ObjectModel.writeActivePersistence
ObjectModel.writeDraftPersistence
ObjectModel.writeEnabled
Semantics.address.city
Semantics.address.country
Semantics.address.label
Semantics.address.postBox
Semantics.address.region
Semantics.address.street
Semantics.address.subRegion
Semantics.address.type[ ]
Semantics.address.zipCode
Semantics.amount.currencyCode
Semantics.businessDate.at
Semantics.businessDate.createdAt
Semantics.businessDate.from
Semantics.businessDate.lastChangedAt
Semantics.businessDate.to
Semantics.calendar.dayOfMonth
Semantics.calendar.dayOfYear
Semantics.calendar.month
Semantics.calendar.quarter
Semantics.calendar.week
Semantics.calendar.year
Semantics.calendar.yearMonth
Semantics.calendar.yearQuarter
Semantics.calendar.yearWeek
Semantics.calendarItem.categories
Semantics.calendarItem.class
Semantics.calendarItem.completed
Semantics.calendarItem.contact
Semantics.calendarItem.description
Semantics.calendarItem.dtEnd
Semantics.calendarItem.dtStart
Semantics.calendarItem.due
Semantics.calendarItem.duration
Semantics.calendarItem.fbType
Semantics.calendarItem.location
Semantics.calendarItem.percentComplete
Semantics.calendarItem.priority
Semantics.calendarItem.status
Semantics.calendarItem.summary
Semantics.calendarItem.transparent
Semantics.calendarItem.wholeDay
Semantics.contact.birthDate
Semantics.contact.note
Semantics.contact.photo
Semantics.contact.type
Semantics.currencyCode
Semantics.eMail.address
Semantics.eMail.bcc
Semantics.eMail.body
Semantics.eMail.cc
Semantics.eMail.from
Semantics.eMail.keywords
Semantics.eMail.received
Semantics.eMail.sender
Semantics.eMail.subject
Semantics.eMail.to
Semantics.eMail.type[ ]
Semantics.fiscal.period
Semantics.fiscal.year
Semantics.fiscal.yearPeriod
Semantics.fiscal.yearVariant
Semantics.geoLocation.cartoId
Semantics.geoLocation.latitude
Semantics.geoLocation.longitude
Semantics.geoLocation.normalizedName
Semantics.language
Semantics.mimeType
Semantics.name.additionalName
Semantics.name.familyName
Semantics.name.fullName
Semantics.name.givenName
Semantics.name.jobTitle
Semantics.name.nickName
Semantics.name.prefix
Semantics.name.suffix
Semantics.organization.name
Semantics.organization.role
Semantics.organization.unit
Semantics.quantity.unitOfMeasure
Semantics.systemDate.createdAt
Semantics.systemDate.lastChangedAt
Semantics.telephone.type[ ]
Semantics.text
Semantics.time
Semantics.unitOfMeasure
Semantics.url.mimeType
Semantics.user.createdBy
Semantics.user.id
Semantics.user.lastChangedBy
Semantics.user.responsible

Next question is how we to get this list. It’s pretty simple, every information in SAP stored in SAP tables itself  in this case ABDOC_CDS_ANNOS

SELECT * FROM ABDOC_CDS_ANNOS where SPRAS = 'E'

SAP ABAP Tutorial and Material, SAP ABAP Certifications, SAP ABAP Study Materials, SAP ABAP Guides

Now I want to explain how to get the list of Annotations used in a given CDS view. Recently I saw few questions in SDN about how to CDS views where Odata extraction is enabled, What are all Query CDS views which are available etc…You can play with SQL for answering questions about CDS meta data.

There were two SAP delivered CDS views one for header information and one for the field information.

Header level Annotations of a CDS view 

//This is select statement
Select
 * from 
 CDSVIEWANNOPOS

//But I want see Annotations of one CDS view so I added where clause as shown below
Select
 * from 
 CDSVIEWANNOPOS 
 where cdsname = 'I_MATERIAL'

This is how I_MATERIAL CDS was defined.

SAP ABAP Tutorial and Material, SAP ABAP Certifications, SAP ABAP Study Materials, SAP ABAP Guides

This is the output of the select statement if we exexute the 2nd SQL shown above code sample

SAP ABAP Tutorial and Material, SAP ABAP Certifications, SAP ABAP Study Materials, SAP ABAP Guides

We can notice highlighted Annotations which doesn’t exist in the CDS , these are the Annotation groups related to the Annotations defined in the CDS.

So I had modified the SQL statement so that output shows only Annotations available in CDS

Select
 * from 
 CDSVIEWANNOPOS 
 where cdsname = 'I_MATERIAL'
 AND ANNOTATIONNAME LIKE '%.%'

SAP ABAP Tutorial and Material, SAP ABAP Certifications, SAP ABAP Study Materials, SAP ABAP Guides

Field level Annotation of a CDS view

select * from 
CDS_FIELD_ANNOTATION
WHERE CDSNAME = 'I_MATERIAL'
and  ANNOTATIONNAME LIKE '%.%'

SAP ABAP Tutorial and Material, SAP ABAP Certifications, SAP ABAP Study Materials, SAP ABAP Guides

No comments:

Post a Comment