Vocabulary-Based Annotation Support in Service Builder - SAP Blogs
Vocabulary-Based Annotation Support in Service Builder - SAP Blogs
Community
Former Member
January 21, 2014 4 minute read
So far using SAP NetWeaver Gateway you can annotate OData elements only with SAP annotations, now it is possible to enhance the metadata with custom-annotations also and this can be
done with vocabulary-based annotation. Basically vocabularies provide the ability to annotate metadata. A vocabulary le is a namespace that contains terms and these terms are used to
annotate OData artifacts.
This blog will explain how you can annotate metadata with consumer speci c vocabulary using SAP NetWeaver Gateway Service Builder tool.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Step-by-Step Procedure
Following are steps which you need to follow
To upload a vocabulary le into the Vocabulary Repository in the Service Builder, proceed as follows:
1. From menu bar choose Extras ->Vocabulary Repository . The central Vocabulary Repository opens and shows a table for displaying the vocabulary ID, version, namespace, and description.
Any previously uploaded vocabulary les are displayed here, otherwise the table is empty.
2. Change to edit mode and choose Append Row to add a new row to the table.
3. Enter a unique vocabulary ID for the vocabulary le you want to upload. Version 1 is assigned automatically to the rst version of
the vocabulary le you upload.
4. Click the Upload icon in the Upload Vocabulary Content column to navigate to the vocabulary le you want to upload. The namespace of the vocabulary le is entered automatically.
5. Enter a description for the newly uploaded vocabulary le.
6. Save the changes and choose Enter.
Create a Project
1. Create a New Project by clicking on
https://blogs.sap.com/2014/01/21/vocabulary-based-annotation-support-in-service-builder/ 1/5
2/10/2020 Vocabulary-Based Annotation Support in Service Builder | SAP Blogs
3. Use any of the available options(like Import ,Rede ne etc) to create OData service.
Import a vocabulary le
In the edit mode, right click on the Data Model, choose Import->Vocabulary in the resulting menu.
The Vocabulary Repository window appears.
Select the required vocabulary(s) and click continue.
In the Tree view a new folder with the name Vocabularies will be created under the Data Model
and the vocabularies imported into this folder.
Double click on the Terms node under the Vocabularies folder to see the details of the imported annotations in the mass maintenance view.
i. Core Type
ii. Type De nition
iii. Enum Type
iv. Complex Type
v. Entity Type
https://blogs.sap.com/2014/01/21/vocabulary-based-annotation-support-in-service-builder/ 2/5
2/10/2020 Vocabulary-Based Annotation Support in Service Builder | SAP Blogs
To add annotations to artifacts for which vocabularies de ne applicable terms, proceed as follows:
Double-click the subfolder that contains the artifacts you want to annotate, for example, Entity Sets. Existing entity sets are listed in the mass maintenance view.
Choose the Annotations pushbutton to see the vocabulary that is valid for these entity sets. If more than one vocabulary de nes applicable terms, you can select the vocabulary you want to
use to annotate the entity set and, if required, toggle between the di erent vocabularies. If none of the imported vocabularies includes applicable terms for entity sets, for example, this
pushbutton is not enabled.
After you have selected the vocabulary you want to use for the annotations, all entity sets are displayed in a table in the mass maintenance view with the name of the applicable vocabulary
displayed as a header.
To create annotations for an entity set, select either the entire row to create all available annotations, or select the applicable cells for each annotation you want to create and choose the
Create Annotation pushbutton. You can select more than one row and more than one cell to enable the mass maintenance of multiple entity sets and annotations, for example.
If you want to delete any annotations, select the relevant rows or cells and choose the Delete Annotation pushbutton.
Save your entries.
In SP7, commented code gets generated for annotation. Follow the instructions provided in method.
You will find new tags namely Annotation Targets in metadata file.
https://blogs.sap.com/2014/01/21/vocabulary-based-annotation-support-in-service-builder/ 3/5
2/10/2020 Vocabulary-Based Annotation Support in Service Builder | SAP Blogs
That is all for now and if need be this blog be enhanced, stay tuned
Alert Moderator Any feedback is highly appreciated
Assigned tags
SAP Gateway |
Related Questions
SEGW: How to switch a project from SAP annotations to vocabulary based annotation?
By Former Member , Dec 18, 2013
Annotations
By Former Member , Jun 23, 2016
6 Comments
Om Band
Very elaborate…
Like (0)
Former Member
Like (0)
Wolfgang Röckelein
https://blogs.sap.com/2014/01/21/vocabulary-based-annotation-support-in-service-builder/ 4/5