Exercise 01 CreateCDSViews
Exercise 01 CreateCDSViews
Description
In this exercise you’ll learn how to create CDS view using ADT and expose as an OData Service using
S/4 HANA system.
System prerequisites
An account on the SAP S/4 System
Introduction
This exercise introduces the ABAP Development Tools (ADT) for SAP NetWeaver also known as
"ABAP in Eclipse". It is the recommended integrated development environment (IDE) for
developing ABAP applications for SAP HANA. This toolset is not mandatory for standard ABAP
development such as creation or maintenance of ABAP reports or ABAP classes. However, it
becomes mandatory for ABAP for SAP HANA development, e.g. for the creation of CDS views or
ABAP managed database procedures as you will see in the corresponding exercises later on. In
such development scenarios, the necessary features are only provided in ADT and not in the
ABAP Workbench (SE80).
The ABAP Development Tools provide a set of powerful tools for developing ABAP applications.
The tools (Eclipse editors and Eclipse views) are ideally positioned in the IDE to facilitate your
tasks.
Explanation Screenshot
1. Install latest Eclipse version Get an installation of Eclipse Neon (e.g. Eclipse IDE for Java
Developers)
2
Create Create CDS View in SAP S/4 HANA
Part 1: Create S/4 HANA System Connection
Explanation Screenshot
3
Create Create CDS View in SAP S/4 HANA
Client: 100
User: developerXX
Password: Welcome1
4
Create Create CDS View in SAP S/4 HANA
Click Next
Click Next
5
Create Create CDS View in SAP S/4 HANA
6
Create Create CDS View in SAP S/4 HANA
Part 2: Create a CDS view
This exercise introduces the CDS view definition capabilities of the AS ABAP 7.5.
In particular, you will learn about the features provided by ABAP CDS like aggregation functions
in the SELECT list, JOINs, UNIONs, the view-on-view capabilities, etc. The exercise is not
designed to give you a complete list, but only an initial peek into the long list of available
features in ABAP CDS.
To learn more about ABAP Core Data Services, see the ABAP language documentation.
As you will see in what follows, we will use the ABAP Development Tools (ADT) to create CDS
views, or more precisely Data Definition Language sources (DDLS). These units of code can
only be created and maintained using ADT, which is one of the reasons why we introduced the
ABAP Development Tools in detail in the previous exercise.
This exercise will show you several useful tips and tricks for working with the CDS editor.
In this exercise, you’ll:
enhance an existing CDS view
create a CDS view
o as a “view-on-view”. That is, a CDS view based on an existing CDS view
o that provides a customer classification based on sales order invoice information
use the Data Preview on CDS views
Explanation Screenshot
7
Create Create CDS View in SAP S/4 HANA
Package: $TMP
Name: ZXC_SOITEMS_XX
Description: Sales Order Items
Click on Next
8
Create Create CDS View in SAP S/4 HANA
Click on Next
9
Create Create CDS View in SAP S/4 HANA
10
Create Create CDS View in SAP S/4 HANA
SOItems.productavailabilitystatus as StatusAvailability,
SOItems.opportunityitem as OpportunityItem
11
Create Create CDS View in SAP S/4 HANA
Package: $TMP
Name: ZXC_SO_XX
Description: Sales Orders
Click Finish
}
As you can clearly see, we
are now selecting from
sepm_iso
12
Create Create CDS View in SAP S/4 HANA
@AbapCatalog.sqlViewName: 'ZX_VW_SO_XX'
20. Let’s add some columns to @AccessControl.authorizationCheck: #NOT_REQUIRED
the view with aliases and @EndUserText.label: 'Sales Orders'
also mark one of the @VDM.viewType: #CONSUMPTION
columns as the key. This is
define view ZXC_SO_XX as
similar to what we did with select from sepm_iso as SO {
the Sales Order Items CDS
view. key SO.salesorderuuid,
SO.salesorder as SalesOrderID,
SO.creationdatetime as DateCreated,
SO.shorttextgroupuuid as NoteID,
Replace CDS View with SO.customeruuid as CustomerID,
code snippet on the right SO.transactioncurrency as TransactionCurrency,
pane SO.grossamountintransaccurrency as GrossAmount,
SO.netamountintransactioncurrency as NetAmount,
SO.taxamountintransactioncurrency as TaxAmount
Replace XX with your }
student number.
13
Create Create CDS View in SAP S/4 HANA
14
Create Create CDS View in SAP S/4 HANA
15
Create Create CDS View in SAP S/4 HANA
16