cancel
Showing results for 
Search instead for 
Did you mean: 

Question about Annotations in Model Provider Class

cain_sun
Participant
0 Kudos

Hi Experts,

We can import vocabulary file to enable annotations in ODATA. And the technical object 'Annotation' itself is nothing but some tags (name and value pairs) to be added to the metadata file, if I am right. So the vocabulary file is somehing like template to generate some codes in MPC for these tags? and actually the tags like sap:label is also some kind of annotation. And SAP Gateway like the document is to add some SAP prefix tags to the odata file?

Some of my questions:

1 where in the MPC is for the annotation generation? In debug stack, i can only find get_model(). But it looks there is nothing about annotation generation in it.

2 For all the EntitySet settings in SEGW, all the configuration/setting will be transferred into a metadata xml when client access the service? So it is at runtime, all these entityset/properties will be transformed?

3 And is there any document about how to use the standard annotation vocabulary like /IWBEP/VOC_COMMON? For exmaple, if I imported it, I can go to annotation of each property and create a new instance in ValueSet. And set another EntitySet as a search help. But for other thing, i am not sure how to use it. if I want to map a Dropdown in UI5 and I need to set some annotation like sap:text. I have no idea how to set it with annotation file.

Accepted Solutions (1)

Accepted Solutions (1)

SB9
Active Participant
0 Kudos

Annotations should essentially be generated at runtime or used by application server to do some activity like dependency injection, etc.

cain_sun
Participant
0 Kudos

Hi Soujanya,

Thanks for your help. Even for the metadata, it is generated at runtime. Breakpoint in the DEFNIE() of MPC class will stop at the first time the service is accessed. But in the MODEL class I did not find where the annotation is composed. I think it is stored in the attribute MT_ANNOTATION(not sure the name) of each Property instance.

These days I tried to understand the Vocabulary file.

From a UI5 table element example, it requires a Annotation 'Lineitem' on Entity Type level with the following value:

<Annotation Term = '...SAP.Vocabularies.UI.V1.LineItem'>

     <Collection>

          <Record Type="...SAP.Vocabularies.UI.V1.DataField">

               <Property Name = '"value" Path="ColumnName" />

          </Record>

     </Collection>

</Annotation?

But in the corresponding /IEWBEP/VOC_UI v1, I found there is no Property called "value" the Complex Property Type DataField, but only "Label".

I tried to copy the vocabulary and add a new Propery in it. But I cannot find the correct Property Type which can return an Annotation like:

<Property Name="Name" Path="ColumnName">

I have tried the following type like Edm.AnnotationPath

Edm.PrimitiveType

Also I tried to search on ODATA version 4 description document on Internet. it tells that Edm.Path is also available, but when I set it in vocabulary file. this propery cannot be used.

----

Answers (1)

Answers (1)

JerryWang
Advisor
Advisor
0 Kudos

Hello Cain,

Regarding your question how to render a drop down list by adding annotation sap:text, you can write ABAP code in your MPC_EXT class, method DEFINE. Please refer to this blog How to build a drop down list using Smart template + CDS view of mine for detail.

Best regards,

Jerry