Explaining SAP Gateway Services Based on CDS Views

Objectives

After completing this lesson, you will be able to:
  • Explain ABAP programming models
  • List OData service development options with CDS
  • Use ABAP Development Tools

ABAP Programming Models

The three phases of the development of an SAP Fiori application are data modeling, service building, and UI development.

Watch the video explaining the key steps of SAP Fiori development. 

Programming model introducing code-based implementation with SAPUI5 in FLP on top connecting via HTTPS to BSPs and SAP Gateway in FES connecting via RFC to SAP Gateway, DPC/MPC, ABAP logic, and application table in S4H

Since SAP NetWeaver 7.0, it is possible to use SAP Gateway to build OData services that access arbitrary business data through existing ABAP frameworks (function modules, RFC, BAPI, SPI…). This can either be done through service development or through service generation using SAP Gateway Service Builder.

For the UI part, SAPUI5 apps are deployed as Business Server Pages (BSP) in the FES and run in the SAP Fiori launchpad (FLP).

Programming model extending code-based implementation with SADL, CDS view, and calculation view in S4H

Since SAP NetWeaver 7.40, it is possible to use CDS views as data source. SAP Gateway uses the Service Adaptation Definition Language (SADL) to access CDS views. There, everything is defined to read data from application tables, so no additional (ABAP) code must be written by any developer.

Requests that perform changes can be implemented using code-based implementation of the create, update, and delete method in the data provider extension (DPC_EXT) class. In addition since 7.50, CDS views referenced as data source in the SAP Gateway Service Builder can be combined with code-based implementation.

Programming model extending SADL with managed runtime and draft table in S4H

Since SAP NetWeaver 7.51 SP01, a first managed runtime is supported that leverages the Business Objects Processing Framework (BOPF). The business objects (ABAP classes) are generated based on appropriate annotations in the CDS view. They are implemented using code-based implementations to call existing APIs performing change requests to business data. This model is called ABAP Programming Model for SAP Fiori (CDS-based BOPF).

Since ABAP Platform 7.54, an enhanced managed runtime is available that leverages CDS behaviors. Therefore, the business objects of CDS-based BOPF are replaced by behavior definitions (ABAP interfaces) and behavior implementations (ABAP classes). This model is called ABAP RESTful Application Programming Model (RAP).

Code-based implementation can still be used to call existing custom code or if CDS views are not suitable to solve the business scenario.

ABAP Programming Model for SAP Fiori

Visualization of ABAP Programming Model for SAP Fiori

Since Application Server (AS) ABAP 7.51, the complete development flow is moving in the direction of metadata-driven development with CDS Views in the center. The pure data definition for accessing the database tables is enriched by metadata extensions consisting of annotations, which can be part of the CDS View or organized in separate files. These annotations can access Enterprise Search, call CDS-based BOPF (Business Object Processing Framework) for CRUD support, or enable the draft concept in SAP Fiori apps, for example.

For the UI part, annotations are used to publish the SAP Gateway service to be consumed by apps based on SAPUI5. If using SAP Fiori elements, the structure and behavior of the UI is completely managed by metadata.

In AS ABAP 7.51, this development flow was introduced as SAP Fiori Programming Model. In AS ABAP 7.54, with the introduction of a second "SAP Fiori programming model", it was renamed to ABAP Programming Model for SAP Fiori.

ABAP RESTful Application Programming Model

Visualization of ABAP RESTful Application Programming Model

Since AS ABAP 7.54, the ABAP RESTful Application Programming Model (RAP) is available based on CDS Views providing CRUD support via SAP Gateway services in SAP Fiori elements. Driven by the evolution of the ABAP Platform in the cloud, the programming model got its way in the on-premise landscape. Compared to the ABAP Programming Model for SAP Fiori, the business objects of CDS-based BOPF got replaced by defining and implementing so-called behaviors. In addition, there is another way of providing SAP Gateway services through service definitions and bindings.

Runtime Implementation Types

RAP offers three types of runtime implementations. Let's have a look on what this means.

OData Service Development with CDS

The four options to develop an OData service with CDS

There are four options to leverage CDS views in an OData service development in SAP Gateway. The options are as follows:

  1. Since AS ABAP 7.40, you can map a CDS view and its associations to the entity sets and navigation properties of an OData service in the SEGW.
  2. Since AS ABAP 7.50, CDS views can be referenced as data source including their associations in SEGW.
  3. Since AS ABAP 7.50, you can publish a CDS view as OData service by implementing the annotation @OData.publish: true in the CDS view using ADT.
  4. Since ABAP Platform 7.54, you can create a service definition and service binding of an OData service for a CDS view using ADT.

Service Adaptation and Definition Language (SADL)

The Service Adaptation Definition Language (SADL) can manage the generic runtime for OData services, which define data models consisting of associations or relations between entities. As a developer, you do not have to know the concrete inner functioning of SADL, as many development tasks are automatically given.

SADL in a nutshell:

  • ABAP framework for OData runtime
  • Dispatches read/write requests
  • Write delegated to managed runtime
  • Read executed directly on CDS View
  • Support for all query options:

    • Counting ($count, $inlinecount)
    • Inlining ($expand)
    • Filtering ($filter)
    • Paging ($top, $skip)
    • Projecting ($select)
    • Sorting ($orderby)

Note

SADL is also known as RAP runtime engine (ABAP RESTful Application Programming Model). Under this term, it is mainly responsible for the runtime orchestration, not for executing the request on a CDS view.

Every option to create an SAP Gateway serivce based on CDS views has pros and cons. All have in common that they are based on consumption views – beside the data source mapping, which can also build on interface views. Because the OData annotations are written directly in the CDS view, publishing a CDS view is the only option the CDS view cannot be reused in other OData services in the same way. For every option, SADL provides fully working read operations.

Beside the availability of an option in a certain release, the crucial difference is the way write operations can be implemented. Options available via SEGW offer a full set of provider classes, which can be implemented freely. Options available via ADT rely on a managed runtime including its limitations. But since the full release of the ABAP RESTful Application Programming Model (RAP) in the ABAP Platform 7.55, this managed runtime offers nearly as much freedom as provider classes including many quality of life features for developers.

The recommendation by SAP is to use business services where available. It is part of RAP and is therefore the most future-proof option. In addition, it is also possible to generate other service types like Information Access (InA) or OData V4.

But the former recommendation by SAP for previous releases has still a major benefit: referencing the CDS view as data source offers the most flexibility in implementing the OData service. You can reuse nearly every ABAP code available no matter how old or how new it is - including RAP.

In the end, the decision of which option to go for is based on what implementations should be reused and what should be achieved with the OData service.

ABAP Development Tools for On-Premise

Screenshot of ABAP Development Tools in Eclipse highlighting button areas to manage projects and perspectives

The ABAP Development Tools (ADT) are a collection of plug-ins for Eclipse supporting development projects reaching beyond pure ABAP. Eclipse is a development environment, originally conceived for Java, that offers a framework for which vendors - including SAP - can provide plug-ins that support development in any given language.

Because different languages and platforms have different requirements, developers need a different set of tools within the same Eclipse window. Such a set of tools is called a perspective combining views and functions suiting for one purpose. There are views showing the source code, structural outline, properties, errors, and many more. Every perspective can be customized, new ones can be created, or existing ones can be reset to the last saved state.

The development objects or source code is organized in projects. Each project defines the frame for the (development) task. The files comprising this task are saved in a local folder.

Screenshots of Eclipse about how to install ABAP Development Tools

To install the plug-ins of ADT, proceed as follows:

  1. Get an installation of Eclipse from https://www.eclipse.org/downloads/packages (for example Eclipse IDE for Java Developers).
  2. In Eclipse, choose HelpInstall New Software....
  3. Enter the URI https://tools.hana.ondemand.com/latest.
  4. Choose Enter to display the available features.
  5. Select ABAP Development Tools and choose Next.
  6. On the next wizard page, you get an overview of the features to be installed. Choose Next.
  7. Confirm the license agreements and choose Finish to start the installation.

ABAP Project

An ABAP project is like any other project in Eclipse a folder with files comprising the development task. For ABAP these are the connection information to an ABAP system. ABAP is a server language, so all source code is saved in an ABAP repository of the ABAP platform.

Watch the video to see how to create ABAP project in ABAP development tools.

The developer needs suitable user authorizations to work via ADT in an ABAP system. A list of roles and authorization objects is available in the following guide:

https://help.sap.com/doc/2e65ad9a26c84878b1413009f8ac07c3/202210.000/en-US/config_guide_system_backend_abap_development_tools.pdf

To enable ABAP developers to share HTTP links between themselves, activate the /sap/bc/adt ICF service. The receiver of the link can then render the target development object in his or her default Web browser

To make documentation available to ABAP developers connected to an AS ABAP lower 7.55, activate the following ICF-services:

  • /sap/bc/abap/docu
  • /sap/bc/abap/toolsdocu
  • /sap/public/bc/abap/docu
  • /sap/public/bc/abap/toolsdocu
Screenshot of an ABAP project in ADT highlighting development objects, editor, outline, and transports

Expanding the System Library in an ABAP project allows direct access to all development objects of an ABAP repository. Especially when accessing an SAP S/4HANA system, this can be quite overwhelming. Therefore, the developer can define favorite packages and objects in an ABAP project.

The Open ABAP Development Object button provides a simple search for development objects based on their names. By choosing a development object from the list, it is opened in the suitable editor and connected views like Outline or Problems.

Many more views allow additional information around developing ABAP. One important one is the Transport Organizer view to open assigned transport requests or create new ones.

Log in to track your progress & complete quizzes