Skip to Content

Question about Annotations in Model Provider Class

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 29, 2015 at 07:49 PM

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

    Add comment
    10|10000 characters needed characters exceeded

    • 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.

      ----

  • Apr 16, 2016 at 03:48 AM

    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

    Add comment
    10|10000 characters needed characters exceeded