---
title: How to Create a Basic Interface CDS View with ABAP
description: See how to create a basic interface core data service (CDS) view with SAP's ABAP development language.
---

[Learn SAP from the Experts | The SAP PRESS Blog](https://blog.sap-press.com)

# [How to Create a Basic Interface CDS View with ABAP](https://blog.sap-press.com/how-to-create-a-basic-interface-core-data-services-view-with-abap)

 Written by [SAP PRESS](https://blog.sap-press.com/author/sap-press) | May 31, 2021 1:00:00 PM

Once you’ve defined a data model and the underlying database tables of an application, you can put a semantic and reusable basic interface CDS layer on top.

 

This blog post will show you how to do this; we’ll adhere to the standard development guidelines of the [SAP S/4HANA](https://learning.sap-press.com/sap-s4hana) VDM based on [CDS views](https://blog.sap-press.com/abap-sql-versus-cds-views-and-amdps-what-to-use#cds-views).

 

The basic interface layer is the foundation layer of CDS views and is directly deployed on top of the database tables. This layer isn’t supposed to do any complex calculations or join large sets of data; instead, this interface layer simply projects the fields provided by the underlying database tables to foster the granular reuse of these views.

                               

To create a CDS view using the [ABAP development tools](https://blog.sap-press.com/an-introduction-to-abap-development-tools) in Eclipse, follow these steps:

1. Open the [ABAP](https://learning.sap-press.com/abap) perspective in the ABAP development tools in Eclipse.
2. In the ABAP project, select the package node into which you want to create the table via the **Project Explorer**
3. Open the context menu by right-clicking on the package and select **New >** **Other ABAP Repository >** **Core Data Services >** **Data Definition**.
4. In the CDS creation wizard that appears, enter a **Name** and **Description**. In our case, we’ll call the purchase documents view `Z_I_PurchaseDocument`and the purchase document items view `Z_I_PurchaseDocumentItem`.
5. Select one of the provided templates to create a skeleton CDS view, for instance, **Define View**, which will create a simple projection view skeleton with one single data source and without any associations or joins.
6. Click the **Finish** button in the wizard, and the source code editor will open so you can add fields or associations to the view.

**Note:** You can use the shortcut (Ctrl)+(Space) inside the field selection section of the CDS view source code editor to trigger the Eclipse content assist popup window to easily select fields of the underlying database table or CDS view, as shown below.

 

 

The code listing below shows the basic interface view for purchase documents, which creates simple projection on the purchase document table (table zpurchdocument) to expose all table fields and provide camel case aliases for fields that are relevant to end users. To follow the naming conventions for interface layer views according to the SAP S/4HANA VDM development guidelines, we named the views using the following pattern: `Z_I_<CDSViewName>`. The Z\_ indicates that a custom developed view in the customer namespace, and the I\_ indicates that this view is an interface layer view. The view is also annotated with the `@VDM.viewType: #BASIC`annotation, which assigns the view to the basic interface view layer of the VDM.

 

In addition to the persistent database fields, the view also contains several associations that are propagated to potential consumers of this view at the end of the field selection list. By convention, associations start with an underscore, for instance, `_ PurchaseDocumentItem`. Usually, most of the (key) fields contained in a view will have foreign key associations to other views because data is supposed to be stored in a normalized and redundancy-free form. In some cases, we omit this for the sake of simplicity, but, as an example, we’ve added associations to the `Priority`, `Status`, and `PurchasingOrganization` views. In the purchase document table, only the `Priority`, `Status`, and `PurchasingOrganization` keys will be stored; however, additional data, like texts, can be read via the foreign key associations to these views.

 

Another important annotation is the authorization check `@AccessControl.authorizationCheck: #CHECK`, which enables restricted access to a CDS view using a data control language (DCL) access control.

 

The `@ObjectModel.representativeKey`annotation defines the field of the primary key that is specific for this view, and the `@ObjectModel.semanticKey`defines the primary key of this view. For the purchase document basic interface view, this field is the `PurchaseDocument` field in both cases. Fields containing descriptions or text should be annotated with @Semantics.text: true. The main description field of the entity can be linked to the entity key with the `@ObjectModel.text.element: ['Description']`annotation.

 

`@AbapCatalog.sqlViewName: 'ZIPURCHDOC'`

`@EndUserText.label: 'Purchase Document'`

`@AccessControl.authorizationCheck: #CHECK`

`@VDM.viewType: #BASIC`

`@ObjectModel.representativeKey: 'PurchaseDocument'`

`@ObjectModel.semanticKey: ['PurchaseDocument']`

`define view Z_I_PurchaseDocument`

`  as select from zpurchdocument`

`  association [0..*] to Z_I_PurchaseDocumentItem as _PurchaseDocumentItem`

`on $projection.PurchaseDocument = _PurchaseDocumentItem.PurchaseDocument`

`  association [0..1] to Z_I_PurchaseDocumentPriority as _Priority`

`on $projection.Priority = _Priority.Priority`

`  association [0..1] to Z_I_PurchaseDocumentStatus as _Status`

`on $projection.Status = _Status.Status`

`association [0..1] to Z_I_PurchasingOrganization as _PurchasingOrganization`

`on $projection.PurchasingOrganization = _`

`PurchasingOrganization.PurchasingOrganization`

`{`

`    @ObjectModel.text.element: ['Description']`

`  key purchasedocument as PurchaseDocument,`

`    @Semantics.text: true`

`    description as Description,`

 

`    @ObjectModel.foreignKey.association: '_Status'`

`    status as Status,`

`    @ObjectModel.foreignKey.association: '_Priority'`

`    priority as Priority,`

`    @ObjectModel.foreignKey.association: '_PurchasingOrganization'`

`    purchasingorganization as PurchasingOrganization,`

 

`    @Semantics.imageUrl: true`

`    purchasedocumentimageurl as PurchaseDocumentImageURL,`

 

`    crea_date_time,`

`    crea_uname,`

`    lchg_date_time,`

`    lchg_uname,`

 

`    // Associations`

`    _PurchaseDocumentItem,`

`    _Priority,`

`    _Status,`

`    _PurchasingOrganization`

`}`

The purchase document item basic interface view is shown in the next listing. Its representative key is the PurchaseDocumentItem field, which is the most specific part of its primary key and defines this entity. The semantic key consists of the PurchaseDocument and PurchaseDocumentItem fields and reflects the primary key of the entity. The purchase document item basic interface view contains a foreign key association to the purchase document view as well as to reuse views for the currency (I\_Currency) and the unit of measure (I\_UnitOfMeasure) provided by the standard SAP S/4HANA basic interface view layer.

 

As soon as views are explicitly released by SAP, you can use them in your own developments without the risk of introducing changes that break the view in future releases. The semantic currency and unit of measure annotations should be known from the table definition. We added the @DefaultAggregation:#NONE annotation to the Price and Quantity fields because all amount fields will be handled, by default, as measures and aggregated by SADL or the Analytical Engine. However, in our case, we explicitly want to suppress this default behavior.

 

`@AbapCatalog.sqlViewName: 'ZIPURCHDOCITEM'`

`@EndUserText.label: 'Purchase Document Item'`

`@AccessControl.authorizationCheck: #NOT_REQUIRED`

`@VDM.viewType: #BASIC`

`@ObjectModel.representativeKey: 'PurchaseDocumentItem'`

`@ObjectModel.semanticKey: ['PurchaseDocumentItem','PurchaseDocument']`

` `

`define view Z_I_PurchaseDocumentItem`

`  as select from zpurchdocitem`

`  association [1..1] to Z_I_PurchaseDocument as _PurchaseDocument on`

`$projection.PurchaseDocument = _PurchaseDocument.PurchaseDocument`

`  association [0..1] to I_UnitOfMeasure as _QuantityUnitOfMeasure on`

`$projection.QuantityUnit = _QuantityUnitOfMeasure.UnitOfMeasure`

`  association [0..1] to I_Currency as _Currency on`

`$projection.Currency = _Currency.Currency`

`{`

` `

`    @ObjectModel.text.element: ['Description']`

`  key purchasedocumentitem as PurchaseDocumentItem,`

` `

`    @ObjectModel.foreignKey.association: '_PurchaseDocument'`

`  key purchasedocument as PurchaseDocument,`

` `

`    @Semantics.text: true`

`    description as Description,`

` `

`    vendor as Vendor,`

`    vendortype as VendorType,`

` `

`    @Semantics.amount.currencyCode: 'Currency'`

`    @DefaultAggregation: #NONE`

`    price as Price,`

`    @Semantics.currencyCode: true`

`    @ObjectModel.foreignKey.association: '_Currency'`

`    currency as Currency,`

` `

`    @Semantics.quantity.unitOfMeasure: 'QuantityUnit'`

`    @DefaultAggregation: #NONE`

`    quantity as Quantity,`

`    @Semantics.unitOfMeasure: true`

`    @ObjectModel.foreignKey.association: '_QuantityUnitOfMeasure'`

`    quantityunit as QuantityUnit,`

` `

`    @Semantics.imageUrl: true`

`    purchasedocumentitemimageurl as PurchaseDocumentItemImageURL,`

` `

`    crea_date_time,`

`    crea_uname,`

`    lchg_date_time,`

`    lchg_uname,`

` `

`    // Associations`

`    _PurchaseDocument,`

`    _QuantityUnitOfMeasure,`

`    _Currency`

`}`

 

## Learn ABAP with Rheinwerk Courses!

Ready to level up your ABAP skills? Explore the full range of our ABAP-focused online courses, from foundational programming to advanced RAP, CDS, AMDP, unit testing, and more. Each one is instructor-led (live and on-demand), includes recordings and slide decks, and is designed to give you practical take-away skills you can apply right away in your SAP landscape. Click on the banner below to get started!

 

<https://www.sap-press.com/online-courses/topics/on-demand-courses/#programming>

## This post showed you how to create a basic interface CDS view using the ABAP programming language.

[View full post](https://blog.sap-press.com/how-to-create-a-basic-interface-core-data-services-view-with-abap)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "SAP PRESS"
  },
  "dateModified" : "2026-03-12T13:49:53.769Z",
  "datePublished" : "2021-05-31T13:00:00Z",
  "headline" : "How to Create a Basic Interface CDS View with ABAP",
  "image" : {
    "@type" : "ImageObject",
    "height" : 443,
    "url" : "https://f.hubspotusercontent00.net/hubfs/5707200/How%20to%20Create%20a%20Basic%20Interface%20Core%20Data%20Services%20View%20with%20ABAP.png",
    "width" : 1440
  },
  "mainEntityOfPage" : "https://blog.sap-press.com/how-to-create-a-basic-interface-core-data-services-view-with-abap",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60.0,
      "url" : "https://cdn2.hubspot.net/hubfs/5707200/rheinwerk-sappress-logo.png",
      "width" : 312.23303
    },
    "name" : "Blog"
  }
}
```