Skip to Content
Author's profile photo Gopal Anand

Hello world to annotations and smart templates with SEGW SAP Gateway


In this blog, I will tell how to create basic annotation, odata service which will hold the annotations and then consume it into a smart template application.

Creating service to read data form table , import and map annotation libarary

Step 1 :  Open any system on your logon.

Use tCode se80  to open your object.

now see the fields of table. it will tell the data type we will use later. let say our table is ZEMPLOYEE (where Z is for customer name spacing).

Now we have table with four fields.

We need something that will link our table with odata service and here comes the role of SERVICE GATEWAY. (we use tcode segw to work on service gateways).

When we work on service gateways we define the MPC(data model definition)  which defines our data fields. entities, their properties and relations.

So now we are going to define the model defination.

In our work bench use tcode segw to start working on service gateways.

2. Create a new project with following fields

choose the package , For me its $TMP for temporaty package.

So we created a project. Cogo 🙂

Let’s give definition to it.

follow the picture now.

steps : go-to Data model

  • create an Entry type

  • We give the entry set name. this will be used later as setter to receive data,
  • In ABAP structure name choose your table ( here i will use ZEMPLOYEE ).
  • Once the Entry type is set . You can see its child. Double click the property under entryType
  • The insert row in yellow will be used to define the properties.
  • The name will be name you give to particular column .
  • ABAP field name will be field name from your table.
  • complete all the fields.

Now we will import the annotation library ( we call it vocabulary).

Steps :


  • Choose the vocabulary as : “SAP UI ANNOTATIONS” this is for the UI definitions.
  • Now comes the part where we need to take care and keep in mind what we are going to make.
  • In our entry type Expand it and find annotations folder.
  • double click on it . we can see the following fields. ( lets assume we are going to create a table)
  • For each collection we will choose its type and value.
  • Type will tell what kind of field it is, value will specify the name we assign (it will appear as column name , value will be linked to our entry types-> property.
  • now the mapping will be like the following picture
  • after all the mappings our line item will look like this.

So with this our annotation definition is completed.

Now we need to do something so that our data definition starts getting data from table and show somewhere along with the annotation we gave.

The time has come when we will register whatever we made as a service. We are going to register it and guess what, after registering we will be having our odata service.

Steps :

  • we will create the runtime artificat. which will have model defination and service defination
  • Now we wll register our service  :
  • the odata service information can be choosed now.
  • Well we are done here . Click on maintain to maintain the service in our gateway
  • A new window will open , choose the SAP gateway client form left side corner.
  • It will lead to following tab. if we execute it we can see our annotations. lets see how it looks like. (Note : we only defined anntotations for our table , not yet got the data for our odata service).
  • What happens when we try to get our entry type. well we have’nt done anything to get data from table . it is going to throw some error let’s see that.

We did the data definition in MPC (the previous steps) . But have not done anything to fetch data from table , so we are getting this error.

To read data we need to implement data provider class (DPC).

the following steps will do this for us.

  • we have our runtime artificates right. open it and double click on _DPC_EXT .
  • press yes . we are going to implement our data provider class to get data from the table.
  • We will redifine our dpc to read data (note we will ne changing the get entity set to read all data, for specific data we can choose get entity.
  • now we need wo write code to read data from table and pass to entity set . I used the following code.
  •  DATA lt_zemployeeset TYPE TABLE OF zemployee.
        SELECT * UP TO 10 ROWS FROM zemployee INTO TABLE lt_zemployeeset.
        APPEND LINES OF  lt_zemployeeset TO et_entityset.
  • the code snippet is like this now :
  • Let’s save and acitvate it.

Hey we did it. we have data in our odata service because we defined the data provider class.

Let’s go back to our service gateway and check the service…

hurrey we got data in our service without any error.


Now the time to see what we did to convert into a result. We will create our first smart template project.

Steps :

  • open webide
  • create a new project
  • choose the list report application
  • give names .
  • choose “com” as application hierarchy.
  • choose the data connection .
  • select the selected service metadata.
  • choose the odata collection and you are good to go.

Run the project as a web applicaiton . press go to see our data. yeah we did it. its up and running.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Gopal,


      which version of GWFND server do you have.  I have 750 but dont see the import option for Annotations.

      SAP_GWFND 750 0005 SAPK-75005 SAP Gateway Foundation

      Author's profile photo Gopal Anand
      Gopal Anand
      Blog Post Author

      Hi Former Member,


      I am using Version 740 where importing annoations is possbile.

      I am not sure about version 750. If i got such system I will test and let you know.


      Best Regards

      Gopal Anand

      Author's profile photo Amrit Kumar Singh
      Amrit Kumar Singh

      Hi Gopal,

      Did you find the issue?  I am not getting the  import option for annotation.



      Author's profile photo Vittal Gopinath Pai
      Vittal Gopinath Pai

      I know its too late to reply to this, but for those of you who face the same issue, its because when creating the new project, you have to choose 'Service with Vocabulary-based Annotations'. By default, this field it set as 'Service with SAP Annotations'.

      Author's profile photo Lorbe C
      Lorbe C

      Is there a way to change the project's setting from 'Service with SAP Annotations' to 'Service with Vocabulary-based Annotations', for a scenario where the project is already created ?

      Author's profile photo wangmo zhu
      wangmo zhu

      hi export :

      I want to ask you how to configure "sap:aggregation-role="dimension"" of the property  and  "sap:semantics="aggregate"" of the entityType  in segw .