Create your first CDS view with the Eclipse-based ABAP Development Tools (ADT)

Create your first CDS view with the Eclipse-based ABAP Development Tools (ADT)

Introduction

You can use this guide to learn how to create a CDS view with the Eclipse-based ABAP Development Tools (ADT).

Step 1: Create a CDS view

Open ABAP Development Tools (ADT) and select your ABAP cloud project.

Now, choose File • New • Other from the main menu. In the dialog box that appears (see Figure 1.1), choose ABAP • Core Data Services • Data Definition.
Confirm your selection by choosing Next.

image.png

Figure 1.1 Selecting the creation of a CDS data model

In the next dialog step, enter the ABAP project, the package, the name of the data definition and its description (see Figure 1.2). Choose Next to confirm your entries.

image.png

Figure 1.2 First dialog step when creating a new data definition

Now, choose the template Define View. Confirm your selection by choosing Finish (see Figure 1.3). This opens the CDS editor. You'll create a CDS view to expose data about sales orders. Enter the same data as depicted in Listing 1.1.

image.png

Figure 1.3 Selecting a template

@AbapCatalog.sqlViewName: 'ZISALESDOCUMENT'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Document'
define view ZI_SalesDocument 
  as select from I_SalesDocumentBasic as SalesDocumentBasic
  association [0..*] to I_SalesDocumentItem as SalesDocumentItem on $projection.SalesDocument = SalesDocumentItem.SalesDocument 
{
    key SalesDocument,
    key SalesDocumentItem,
    SalesOrganization,
    DistributionChannel,
    OrganizationDivision,
    CreatedByUser,
    CreationDate,
    LastChangedByUser,
    LastChangeDateTime
}

Listing 1.1 CDS view ZI_SalesDocument

Step 2: Test yourself

In the CDS editor context menu, choose Open With • Data Preview or press F8 to display the data preview with the result of the automatically executed selection from CDS view ZI_SalesDocument.

Summary

In this tutorial, you learned about creating a CDS view in the Eclipse-based ABAP development environment. You can use it to construct apps that need to retrieve data about sales orders.