To improve the support of code pushdown and the integration of the necessary database objects into the ABAP development process, SAP has enhanced the functional scope of Open SQL and ABAP database views even further since SAP NetWeaver AS ABAP 7.4 SP 5. In this chapter, we’ll introduce the new features.
6Advanced Database Programming with ABAP 7.4
To use the code-to-data paradigm in ABAP applications, you require the corresponding means to implement and execute the processing logic in the database. Chapter 5, Section 5.1.2 and Section 5.2.2, described how you can use SAP HANA development objects for this purpose. However, you might have noticed that using these objects can also lead to problems.
In contrast to objects that are completely managed by AS ABAP, the following restrictions apply to the development of SAP HANA development objects and the usage of the corresponding replacement objects in ABAP (external view and database procedure proxies):
-
SAP HANA development objects aren’t integrated fully with ABAP Lifecycle Management.
-
If SAP HANA development objects are changed, the respective replacement objects and SAP HANA transport containers, which are managed by the ABAP Data Dictionary (DDIC), need to be synchronized manually.
-
SAP HANA development objects aren’t linked to the ABAP version management.
-
-
SAP HANA development objects aren’t considered in the syntax check and activation of the ABAP application. The ABAP runtime environment doesn’t display errors and warnings relating to SAP HANA development object implementations. This often leads to runtime errors.
-
SAP HANA development objects and consequently their replacement objects can’t be extended.
-
You can’t map SQL data types to DDIC data elements in external views. If you use these replacement objects in user interfaces (UIs), the field labels and short descriptions are missing at first.
-
To implement SAP HANA development objects, ABAP developers require an additional user for the SAP HANA database and the corresponding database authorizations.
This chapter introduces the new database programming and code pushdown options in ABAP. ABAP manages the resulting objects to ensure a familiar integration of the objects into ABAP Lifecycle Management, including version management and object extensibility. We’ll discuss the following enhancements, which have been developed since ABAP 7.4 SP 5:
-
The advanced functional scope of ABAP database views within the scope of Core Data Services (CDS; see Section 6.1)
CDS are used to define persistent data models. -
New Open SQL features
These include, for example, support of SQL expressions in the SELECT list and in the GROUP BY, HAVING, and WHERE clauses of SELECT statements (see Section 6.4). -
Implementing SAP HANA database procedures in ABAP methods
These ABAP Managed Database Procedures (AMDP) enable you to execute processing logic in the database (see Section 6.5). You can implement these database procedures in the normal ABAP development environment without requiring a user for the SAP HANA database.
6.1Introducing Core Data Services
Core Data Services (CDS) are a specific SAP method of defining persistent data models. The specification is based on the SQL-92 and SQL:1999 standards. Just like SQL, CDS define a data definition language (DDL) and a data control language (DCL). They also define a query language (QL). You can use the DDL, for example, to describe database tables and structured types. The QL allows you to read data in a comfortable way and is used in combination with DDL to define database views. The DCL enables you to define access restrictions for CDS objects.
CDS additionally contain the following SQL enhancements that are necessary to create optimal data models for business applications:
-
Annotations
These are used to enrich CDS objects with additional metadata, which can’t be expressed in SQL. This metadata can also be queried and used by client applications. Client applications can also define their own annotations and store their own metadata together with the data model. -
User-defined, scalar, and structured data types
These are used to better illustrate the semantics of the data types used. -
Associations
These are used to define the relationships between CDS objects. During the modeling process and when data is read from the database, you can use path expressions to address relationships that have been described with associations.
The CDS specification is implemented in SAP NetWeaver AS ABAP and in SAP HANA. These implementations were made mainly independently of each other. Although the CDS implementation in AS ABAP (also referred to as ABAP CDS) leverages the infrastructure of the ABAP AS with mainly database-independent ABAP CDS objects, the CDS implementation in SAP HANA (also referred to as SAP HANA CDS) is fully bound by the conditions of the SAP HANA database. So currently, you can’t use SAP HANA CDS objects in AS ABAP or ABAP CDS objects in SAP HANA.
Despite the different implementations, you can benefit from the shared specification: CDS describes a uniform and—due to the enhancements—expressive syntax for data modeling. If you are familiar with this syntax, you’ll easily understand the models irrespective of where they are implemented. CDS also harmonize further data modeling aspects. For example, CDS define how you can enhance data models. This enables SAP customers and partners to adapt existing ABAP or SAP HANA CDS objects to their requirements in the same way. Finally, because CDS are based on the SQL-92 and SQL:1999 standards, many functions already familiar to you from SQL are available to implement the code pushdown in your data models.