6.3SAP HANA Core Data Services
Although SAP HANA CDS currently plays a minor role in the development of ABAP applications on SAP HANA, we’ll provide a brief overview on this variant. SAP HANA CDS is driven by the requirements of the native application development for SAP HANA. SAP implements functions purposefully; that is, it provides functions that use the SAP HANA architecture and in-memory data processing optimally and support the application development in the SAP HANA environment.
Among other things, you can use SAP HANA CDS for the definition of the following CDS objects:
-
Database tables
-
SQL views
-
Associations
-
User-defined scalar and structured data types
You define SAP HANA CDS objects in a separate file. To do so, you need an SAP HANA database user with the corresponding authorizations. The object files and the SAP HANA catalog objects that were generated from them are subject to SAP HANA Lifecycle Management. This close integration of the CDS objects with SAP HANA means that they are difficult to consume in ABAP applications and synchronize with other ABAP objects. Therefore, ABAP CDS are usually used for application development in ABAP.
Although SAP HANA CDS objects are usually not used in ABAP applications, we’ll take a look at the SAP HANA CDS syntax for comparison reasons. In SAP HANA CDS, several CDS objects can be defined in a file. Listing 6.15 shows the definition of two database tables (Address and Partner) and one view (Supplier) in SAP HANA CDS. The semantically related objects are grouped in one context. The @Catalog.tableType annotation determines which table type is supposed to be created in the database. The relationship between the entities is modeled using the _Address association.
@Catalog.tableType : #COLUMN
define entity Address {
key id : Integer;
city : String(40);
postalCode : String(10);
street : String(80);
countryCode : String(3);
};
@Catalog.tableType : #COLUMN
define entity Partner {
key id : Integer;
addressId : Integer;
role : String(3);
companyName : String(80);
_Address: association[1] to Address
on addressId = _Address.id;
};
define view Supplier as select from Partner {
id,
'SUPPLIER' as role,
companyName,
_Address.street,
_Address.countryCode
} where role = '02';
};
Listing 6.15Sample Syntax of SAP HANA CDS
Although the functional scope of ABAP CDS and SAP HANA CDS differs, the data model is easy to understand, and the syntax is consistent for the shared functions. We could define this view in the same way in ABAP CDS but would have to replace the Partner data source with a CDS view. This harmonization facilitates the access to the native SAP HANA data models and a migration to in-memory development, for example, in side-by-side scenarios.
[»]Additional Information on SAP HANA CDS
You can find more information on SAP HANA CDS in the SAP HANA Developer Guide for SAP HANA Studio in the SAP Help Portal (http://help.sap.com).