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'
You can check SAP help on these Annotations using the below link
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.
This is the output of the select statement if we exexute the 2nd SQL shown above code sample
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 '%.%'
Field level Annotation of a CDS view
select * from CDS_FIELD_ANNOTATION WHERE CDSNAME = 'I_MATERIAL' and ANNOTATIONNAME LIKE '%.%'
Hope this blog will give kick start on the annotations.
Please leave your comments and suggetions so that I can add if anything missing or wrong.
What an awesome blog....bro just one thing is missing, which annotation i have to use on which scenario. if you can guide me for it would be really helpful.
Please use below in for the documentation
Hello Andre - The author (Shanti Bhaskar) has copied the content from the below link and posted it here as his blog post. This author is a plagiarism king and all he does is to copy the contents from other sites and post it here as his own post. The entire post has been copied and pasted here blindly. Following is the link from which he has copied:
Kindly review the same and request you to take the strictest of action against such people who are destroying this wonderful forum.
PS: The other blog posts of this user are also copied content from the web. One such example is the CDS view finder which he copied from SAPYARD (https://blogs.sap.com/2020/05/31/abap-cds-view-finder/). After I posted my comment on plagiarism, looks like this blog has now been deleted.
That other community post is currently off the site, as we are currently working with Shanthi on how to resolve.
In this case, Shanthi's post was published on December 6. The other was published on December 7 (http://sapabapcentral.blogspot.com/2019/12/all-about-cds-annotations.html). Considering that the time stamps are also dependent on time zones, we'd have to investigate further to see whether, in fact, this post actually came first (in which case someone else plagiarized this, and not the other way around).
One thing missing from the other is that Shanthi includes references to SAP Help and has also been knowledgeable enough to point people to that content in comments:
You can check SAP help on these Annotations using the below link
Thanks for your support.
Sorry for commenting so late here, Was very busy with Group reporting implementation.
Previously I had wrote a blog ABAP CDS View(s) Finder where I had referenced their blog and clearly I had mentioned source. But it was deleted as requested by SDN Moderator. Now they are doing revenge drama on me .
Not sure what are they doing these kind of actions. After seeing a year like 2020 still people try to defame people unnecessary with Negative thoughts :(.
I am vivid learner and passionate SAP guy and always try to share the things. I had learnt so much and been learning here (SAP SCN), So will be keep posting the stuff as I learn.
Please refer the below screen cam where email time and date can be seen. I always keep track of my learnings in emails.
Please check this thread - The original reason why I had published this blog.
Shame on you Shanti Bhaskar for copying the content from other sites and posting it here as your own post.
Hi Shanthi Bhaskar, this blog is really helpful, But I had one doubt can we implement variant using CDS annotations?
I am not sure we have that option Shilpa.
Ok thank you for your reply