Skip to Content
Technical Articles
Author's profile photo Urvashi Tibrewal

How to add annotations to an OData service without using code

In this post I will showcase some of the features controlled by OData annotations. With the use of annotations in OData, we can minimize the UI View code to be written for conventional scenarios like showing text and filtering data.

Example 1: Showing search help for Filter in Personalization Dialog

Example 2: Showing Text

Example 1

The p13n dialog control provides a dialog for tables that allows the user to personalize one or more of the following attributes:

  • Columns
  • Sort
  • Filter
  • Group

 

The third tab is the Filter tab, which allows the user to filter based on specific criteria.

The filter criteria can be included or excluded in the relevant section of the filter.

The user selects the column to be filtered. Any of the columns can be selected from the dropdown.

The second field offers an operator for specifying the filter in more detail. The operators that are available depends on the data type of the selected column.

Scenario

Created OData ‘ZTEST_SEARCHHElP’

Main Entity: Customer

Value Help Entity: Customer Value Help

Click on Annotation at properties

Click on com.sap.vocabularies.Common.v1

Click on ValueList-> Create Annotation

Pass the ValueHelp Entity in label and ValueHelp Entityset in CollectionPath

In Parameters

For ValuelistParameterInOut

For ValueListParameterDisplay

In DPC_EXT we need to implement the CustomerValueHelp entityset to fetch the value

2> Text name

We need to Click on Annotation->com.sap.vocabularies.Common.v1->Text

Create Annotation and pass the name of the customer

The value will be displayed as below.

Assigned Tags

      12 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Christian Kloy
      Christian Kloy

      Hi, thanks for this great blog.

      I also use this Annotation-Feature in the Service-Builder, but one thing is missing: Where can I define the Qualifiers for some Annotations, e.g. "FieldGroup"?

      In the Annotation-Modeler of the Web-IDE is it maintenable:

      Author's profile photo Urvashi Tibrewal
      Urvashi Tibrewal
      Blog Post Author

      Hi . Thanks for the Compliment

      We can define Field Group in com.sap.vocabularies.UI.v1

       

      Author's profile photo Vijay Sharma
      Vijay Sharma

      nice. Thanks for Sharing Urvashi Tibrewal !

      Author's profile photo Urvashi Tibrewal
      Urvashi Tibrewal
      Blog Post Author

      Thank You

      Author's profile photo sofia alston
      sofia alston

      Nice Post! Thanks for sharing such an amazing article, really informative,it helps me a lot.

      Author's profile photo Urvashi Tibrewal
      Urvashi Tibrewal
      Blog Post Author

      Thank You

      Author's profile photo Julius Tanuy
      Julius Tanuy

      Hi Urvashi Tibrewal

      Thanks for sharing. If it is possible, do u have any idea for my question? https://answers.sap.com/questions/13107727/annotation-segw-travel-request-v2.html

       

      Thanks.

      Author's profile photo Yury Hotsman
      Yury Hotsman

      Hello  Urvashi Tibrewal

      In my SEGW transaction I don't have this button "Annotations". Do you know what I need to setup or customize to add this button?Annotations

      Annotations

      Author's profile photo Arul Deva Rajakumar
      Arul Deva Rajakumar

      Hello Yury,

      I have the same problem, I am not able to see the Annotations button.

      Did you manage to find the answer?

      Regards,

      Arul.

      Author's profile photo Urvashi Tibrewal
      Urvashi Tibrewal
      Blog Post Author

      When you are creating the project please select Service with Vocabulary based Annotation as Project type

      Author's profile photo Zuma Xu
      Zuma Xu

      Even though I can see the Annotations button, but it's gray. I can do nothing about it.

      Author's profile photo Zuma Xu
      Zuma Xu

      Solved, by doing one step:

      1. Import the vocabulary in the OData – Right click on Data Model -> Import -> Vocabulary