Skip to Content
Author's profile photo SIMMACO FERRIERO

How to create Smart Templates annotations within CDS views – part 1


Maybe all of you know what is a view in a database: a view is an entity that is not persistent; it is defined as the projection of other entities. In this H2G we are going to see how to build a special kind of view, a CDS (Core Data Service) View, which contains some new technology concepts called Annotations.

Let’s move step by step.

What’s CDS?

“CDS is an infrastructure layer for defining semantically rich data models, which are represented as CDS views. In a very basic way, CDS allows developers to define entity types (such as orders, business partners, or products) and the semantic relationships between them, which correspond to foreign key relationships in traditional entity relationship (ER) models. CDS is defined using a SQL-based data definition language (DDL) that is based on standard SQL with some additional concepts, such as associations, which define the relationships between CDS views, and annotations, which direct the domain-specific use of CDS artifacts.”

(cit. Enhanced ABAP Develoment with Core Data Services (CDS)</title><meta name="news_keywords" content=&qu…)

In our case we are going to use CDS views combined with OData annotations.

“The term annotations implies attaching data to another piece of data. Annotations are used in different areas; one area would be the semantic annotations, which determines what the OData properties contain, e.g. a phone number, a part of a name or address, or something related to a calendar event or an analytic query. This type of annotations are important for the applications running on mobile devices to seamlessly integrate into contacts, calendar, and telephony.

The second area is the capability annotations that describe the possible interactions defined by OData’s uniform interface and the supported parts of a concrete service. These annotations will tell whether an entity set allows inserts, updates, or deletes, whether it requires a filter or which properties can be used in filter expressions. They also advertise capabilities that go beyond the base set defined by OData, e.g. whether an entity set allows free-text search via an SAP-defined query option.” (cit. OData Model Editor for SAP Web IDE)

This means that with annotations, which I’ve already talked about in  my previous blog here, we can define, in the view itself, how data have to appear when we are consuming them.

In particular, if we build an app starting from Smart Templates, this can automatically get the information regarding how to display backend data, from the annotations specified in the CDS views on which the service is defined.

In this blog we are going to see exactly this: we will start by building a CDS view on the ABAP backend, we will define some annotations in the view, we will end by building an app from Smart Templates with SAP Web IDE and we will integrate the annotation information coming from the backend with some other annotations defined in the app itself.

This blog has been split in 3 parts:

Link Content
This part Development tool installation and DDL Source creation
How to create Smart Templates annotations within CDS views – part 2 Service registration and Smart Template creation in the NW Gateway and consumed by Smart Templates
How to create Smart Templates annotations within CDS views – part 3 Enhancing the annotation


If you have followed my previous blog on Smart Templates you have seen how to create a new Smart Templates app from scratch. The annotation file was created as a XML file in the application itself. Here we want to do the same: obtain the same result, the same final application, but putting as many annotations as possible in the CDS view and create only a very small annotation file in the app.


  1. JRE version 1.6 or higher, 32-Bit or 64-Bit
  2. Eclipse Mars (4.5) or Luna (4.4)
  3. SAP GUI: SAP GUI for Windows 7.40 or SAP GUI for Java 7.40 for Apple Mac or Linux (SAP GUI Download)
  4. Microsoft VC Runtime


  1. Installation of Eclipse and its ADT plugin
  2. DDL Source creation
  3. Service registration and Smart Template creation in the NW Gateway and consumed by Smart Templates
  4. Configure HANA Cloud Connector and create a destination
  5. Create a new app from a Smart Template
  6. Enhancing the annotation

Step 1: Installation of Eclipse and its ADT plugin

In order to be able to create CDS Views you need first to configure your development environment. The development tool for this kind of object is Eclipse equipped with the SAP ADT plugin. In this chapter we are going to see how to prepare your development environment. Before you start I’m assuming you have already installed a JRE and a SAP Gui on your workstation. They are both needed for our environment. Eclipse can be downloaded directly from Eclipse Downloads

1 – Select one of the two versions you want to use, Luna or Mars (I’m using Mars in this guide), and download it on your workstation

2 – Extract it in the desired folder

3 – Run Eclipse by double clicking on its icon/wp-content/uploads/2016/05/01_942772.png

4 – Choose for now the proposed workspace

5 – Go on Help –> Install new software

6 – Paste the link ( (updated info can be found here) and click on Add; specify a name for this plugin and click on OK


7 – Select ABAP Development Tools for SAP NetWeaver and choose Next


8 – On the next wizard page, you get an overview of the features to be installed. Choose Next


9 – Confirm the license agreements and choose Finish to start the installation

10 – Restart Eclipse when required

11 – After restarting click on Go to Workbench


Step 2: DDL Source creation

In order to create a CDS View we first need to create a DDL Source. Such kind of object can be created in Eclipse by the following procedure:

1 – Create a new ABAP project by clicking on the menu File –> New –> Project –> ABAP –> ABAP Project and then click on Next

2 – Enter the System ID, the Application server and the Instance number and click on Next


3 – Enter the Client Number, the Username, the Password and the chosen Language then click Next


4 – Specify a name for the project or leave the proposed one then click on Finish


5 – You will be asked to open the ABAP Perspective. Answer Yes

6 – A default favorite local package should be already available for you. Right click on this package and choose New –> Other ABAP Repository Object. Type “ddl” in the filter box, choose DDL Source and click on Next


7 – Give a name to the DDL Source (i.e. Z_SAMPLE_DEMO_SOLI) and a description (i.e. Sample Demo Sales Orders Line Items) then click on Next


8 – Click again on Next at the Selection of Transport Request screen

9 – Use the template Define View and click on Next


10 – We are ready to create our first simple view. Paste the following code in the editor

@AbapCatalog.sqlViewName: ‘Z_VW_SOLITEMS’

@AbapCatalog.compiler.compareFilter: true

@AccessControl.authorizationCheck: #CHECK

@EndUserText.label: ‘Sales Order Line Items’

define view Z_Sample_Demo_Soli

  as select from sepm_isoi as SOLItems


  key SOLItems.salesorderitemuuid,

      SOLItems.salesorderuuid                     as SalesOrderID,

      SOLItems.salesorderitem                     as ItemPosition,

      SOLItems.productuuid                        as ProductID,

      SOLItems.shorttextgroupuuid                 as NoteID,

      SOLItems.transactioncurrency                as CurrencyCode,

      SOLItems.grossamountintransaccurrency       as GrossAmount,

      SOLItems.netamountintransactioncurrency     as NetAmount,

      SOLItems.taxamountintransactioncurrency     as TaxAmount,

      SOLItems.productavailabilitystatus          as StatusAvailability,

      SOLItems.opportunityitem                    as OpportunityItem


11 – Save the file and activate it, you should not get any error


12 – You can test the view by pressing CTRL+F11 on Windows or by clicking on the green play button on the toolbar. When asked, choose to run the view as an ABAP Application. You should get something like this


13 – Repeat the same steps for creating a new DDL Source named Z_SAMPLE_DEMO_PRODUCTS with the description Sample Demo Products

14 – Paste this code in the view, save and activate it


@AbapCatalog.sqlViewName: ‘Z_VW_PRODUCTS’

@AbapCatalog.compiler.compareFilter: true

@AccessControl.authorizationCheck: #CHECK

@EndUserText.label: ‘Products’

define view Z_Sample_Demo_Products

  as select from sepm_iproduct as Products

  association [1..*] to Z_Sample_Demo_Soli as _SOItems  on  $projection.productuuid = _SOItems.ProductID

  association [1..1] to sepm_iproductt     as _ProductT on  $projection.productuuid = _ProductT.productuuid

                                                        and _ProductT.language      = ‘E’

  association [1..1] to sepm_ibupa         as _Supplier on  $projection.supplieruuid = _Supplier.businesspartneruuid


  key Products.productuuid,

      Products.product                                                       as ProductID,

      Products.producttype                                                   as TypeCode,

      Products.productcategory                                               as Category,

      _ProductT.productname                                                  as Name,

      ‘EN’                                                                   as NameLanguage,

      _ProductT.productdescription                                           as Description,

      ‘EN’                                                                   as DescriptionLanguage,

      _Supplier.businesspartner                                              as SupplierID,

      _Supplier.companyname                                                  as SupplierName,

      Products.productvalueaddedtax                                          as TaxTarifCode,

      Products.productbaseunit                                               as MeasureUnit,

      Products.weight                                                        as WeightMeasure,

      Products.weightunit                                                    as WeightUnit,

      Products.currency                                                      as CurrencyCode,

      Products.price                                                         as Price,

      Products.width                                                         as Width,

      Products.depth                                                         as Depth,

      Products.height                                                        as Height,

      Products.dimensionunit                                                 as DimUnit,

      Products.creationdatetime                                              as CreatedAt,

      Products.lastchangeddatetime                                           as ChangedAt,

      concat(concat(‘/webapp/images/’,Products.product),‘.jpg’)              as PictureUrl,




15 – You can test this view as well by pressing the play button


Let me spend a few words on these two views.

In the first view, Z_SAMPLE_DEMO_SOLI, I’m just selecting some fields form the EPM table sepm_isoi containing all the sales orders line items. I’m asserting that the key for this table is SOLItems.salesorderitemuuid and that the fields have some predefined names.

In the second view, Z_SAMPLE_DEMO_PRODUCTS, I’m creating an association between the table sepm_iproduct and the view defined earlier, so that for each product I can see all the sales order line items related to that product. Further to this I’m also doing another association with the table sepm_iproductt in order to get the name and the description of the product and with the sepm_ibupa to get some information about the business partner as well.

NOTE 1: probably you have noticed that I’m creating a PictureUrl column by concatenating the following 3 pieces:

‘/webapp/images’ the name of the product ‘.jpg’.

I did it in this way to reflect the work I did in my previous blog with smart templates. Of course you could extract the PictureUrl field directly from the database, but in this case, after creating the app in SAP Web IDE, you should add a new section in neo-app.json file to map the backend resource.

NOTE 2: at the end of the view you see I’ve also added “_SOItems”: this means that I want to show also all the fields of the first view Z_SAMPLE_DEMO_SOLI. In this way, the service will present it as a new entity linked to the first one in the metadata.xml file.

Let’s continue now with the second part of this blog to understand how to create a new service for this view and how to consume it in a Smart Template app.

Assigned Tags

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


      We don't have HANA public facing server so it doesnt support the cloud connectivity hence we are not able to perform smart template on Web IDE.

      Is any alternate platform available, if available please provide some links...


      Author's profile photo SIMMACO FERRIERO
      Blog Post Author

      Hi Amol,

      not sure if you fully understood your question. You can try to use our free trial landscape. You only need to create your account here Cloud Cockpit and you can use for free all the HCP features with some limitations of course.



      Author's profile photo Amol Samte
      Amol Samte


      Actually, the bottom line is we are not allowed to connect Web IDE.

      -Amol S

      Author's profile photo Former Member
      Former Member


      you can connect to HCP trial cockpit, Enable the Web IDE in the subscription. and in the list of services in your account, you can search for web ide and click on the Go to Web IDe.

      Author's profile photo Former Member
      Former Member



      I had followed your steps a while back and I was able to create a new data definition.

      Recently when I try to create/open an existing data definition, I keep getting the below error.

      No matter how many times I say "update now", the update happens and the error popup comes again when I try to reopen it. Any idea how I can resolve this?

      I am using eclipse mars.

      Author's profile photo Smriti Gupta
      Smriti Gupta

      Hello Simmaco,


      Thanks for posting this series of blogs consuming epm model. It's very well documented..