0% found this document useful (0 votes)
8 views10 pages

ABAP for Cloud Development Guide

RAP Basics
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views10 pages

ABAP for Cloud Development Guide

RAP Basics
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ABAP Language Version

The present documentation is based on ABAP for Cloud Development. All


described features are applicable using the restricted set of language elements
and repository objects that are released for cloud development. For cloud
products, only the language version ABAP for Cloud Development is available. In
classic ABAP development environments you can choose the ABAP language
version. Developing RAP applications with ABAP for Cloud Development is
recommended for all ABAP development environments as this is key for your
developments to be upgrade-stable, cloud-ready, software-architecture-driven
and thus future-proven.
Validity of Documentation
The ABAP RESTful Application Programming Model guide is valid for the following
products:
 SAP S/4HANA Cloud Public Edition
 SAP BTP ABAP environment
Note
To highlight the specifics for SAP BTP and SAP S/4HANA Cloud releases, the  icon
is used.
This documentation reflects the latest feature scope of ABAP development tools
for Eclipse (ADT) that is shipped with the latest backend versions of the
supported SAP products.
Prerequisites
To start developing with the ABAP RESTful Application Programming Model, make
sure you meet the prerequisites. See Prerequisites.
Constraints
The current version of the ABAP RESTful Application Programming Model still has
some constraints for certain features. For a detailed list, see Development
Constraints.
The ABAP RESTful Application Programming Model and ABAP Cloud
The ABAP RESTful Application Programming Model (RAP) was designed to
improve upon the ABAP Programming Model for SAP Fiori. RAP was designed to
incorporate lessons learned from the previous model. RAP enhanced key
architectural concepts that are now integral to ABAP Cloud, like separating the
business logic implementation and protocol-specific parts. RAP allows you, for
example, to expose the same RAP business object for OData V2 and OData V4.
This means that the same implementation can be used for multiple business
services, which increases efficiency and reusability. This became a best practice
for other scenarios, including embedded analytics and integration services. The
ABAP Cloud development model incorporated all best practices from RAP,
starting with an architecture blueprint based on a model-driven approach.
In ABAP Cloud, you develop transactional apps and services with RAP. For more
information about the different use cases in ABAP Cloud, see Broad Use Case
Coverage in the ABAP Cloud: Background Concepts and Overview.
Data Modeling and Behavior
The layer of data modeling and behavior deals with data and the corresponding
business logic.
Data Model
The data model comprises the description of the different entities involved in a
business scenario, for example travel and booking, and their relationships, for
example the parent-child relationship between travel and booking. The ABAP
RESTful Programming Model uses CDS to define and organize the data model.
CDS provides a framework for defining and consuming semantic data models.
Every real-world entity is represented by one CDS entity. View building
capabilities allow you to define application-specific characteristics in the data
model. That means, CDS entities are the fundamental building blocks for your
application. When using the CDS entity for a data selection, the data access is
executed by the SQL-view, which is defined in the CDS entity.
Depending on the use case, data models support transactional access or query
access to the database. Thus, data models are used in business objects or
queries respectively.
The following diagram gives you an overview of the data model that is used in
the development guides in chapter Develop of this documentation. Every block
refers to one database table view and the respective CDS entity. The blue boxes
represent a Travel business object, with its child entities Booking and Booking
Supplement. The white boxes represent the entities that are not part of the
business object, but support with value helps or text associations. For read-only
access to the database, that is simple data retrieval, the data model is used for
the query.
Data Model Used in the Development Guides of this Documentation
The following diagram shows the data model used in development
guide Extend to showcase the possibilities for extending existing business
objects.

Behavior
The behavior describes what can be done with the data model, for example if the
data can be updated.
In transactional scenarios, the business object behavior defines which operations
and what characteristics belong to a business object. For read-only scenarios, the
behavior of the data model is defined by the query capabilities, for example if
the data is filterable.
Learn more about the business object and the query in the following topics.
Runtime Frameworks
The runtime frameworks SAP Gateway and the RAP Runtime Engine are the
frameworks that manage the generic runtime for OData services built with the
ABAP RESTful Programming Model. As a developer you do not have to know the
concrete inner functioning of these frameworks, as many development tasks are
automatically given. However, the following sections provide a high-level
overview.
SAP Gateway
SAP Gateway provides an open, REST-based interface that offers simple access
to SAP systems via the Open Data Protocol (OData).
As the name suggests, the gateway layer is the main entry point to the ABAP
world. All services that are created with the ABAP RESTful Programming Model
provide an OData interface to access the service. However, the underlying data
models and frameworks are based on ABAP code. SAP Gateway converts these
OData requests into ABAP objects to be consumed by the ABAP runtime.
RAP Runtime Engine
The RAP runtime engine dispatches the requests for the business object (BO) or
the query. It receives the ABAP consumable OData requests from the Gateway
layer, forwards it to the relevant part of the business logic and interprets the
matching ABAP calls for it. For transactional requests, the RAP runtime engine
delegates the requests to the BO and calls the respective method of the BO
implementation. For query requests, the framework executes the query.
Depending on the implementation type, the BO or the query runtime is
implemented by a framework or by the application developer.
If locks are implemented, the RAP runtime engine executes first instance-
independent checks and sets locks. For the eTag handling, the framework calls
the necessary methods before the actual request is executed.
Note
The RAP runtime engine is also known under the name SADL (Service Adaptation
Description Language). Apart from the runtime orchestration, the SADL
framework is also responsible for essential parts in the query and BO runtime.
Examples
The OData client sends a DELETE request, which is converted to an object that is
understandable for ABAP. The RAP runtime engine analyzes this ABAP object and
triggers the MODIFY method for DELETE of the business object to execute
the DELETE operation on the database table. Depending on the implementation
type (managed or unmanaged), the code for the MODIFY method is generically
available or must be implemented by the application developer.
Likewise, if an OData request contains a query option, such as $orderby, the
Gateway layer converts it to the query capability SORT. Then, the RAP runtime
engine takes over and delegates the query capability to the query. Depending on
the runtime type (managed or unmanaged), the query is executed by the generic
framework in case of managed type or by the self-implemented runtime in case
of unmanaged type. For a managed query, the generic framework converts the
requests to ABAP SQL statements to access the database.
Why learn RAP?
The requirements for SAP business applications and their associated
technologies have evolved significantly over the past years. Besides increasing
requirements for embedded analytics and artificial intelligence, the main drivers
of this evolution are:
• SAP HANA – the high-performance in-memory database for real-time
transactional and analytical processing.
• SAP Fiori – the chosen, modern, intuitive, and cross-device UX design for the
Intelligent Enterprise.
• Cloud – with the increasing business needs for cloud operation support,
ranging from hybrid, i.e., cloud and on-premise, to exclusively cloud operation
models.
End users expect enhanced product qualities such as continuous and
collaborative work – e.g., to start working at home, continue during commuting,
and finalize the task at the company, or to accomplish tasks on different device
types or collaboratively.
Product qualities - such as scalability, testability, supportability, extensibility,
verticalization, and documentability - must be available out-of-the-box.
To meet these various requirements on the ABAP platform, SAP offers the ABAP
RESTful Application Programming Model (RAP) on SAP BTP ABAP
Environment and SAP S/4HANA, on-premise as well as in the cloud.
What is RAP?
The ABAP RESTful Application Programming Model (RAP) is an essential
element of ABAP Cloud, the ABAP development model for building clean core
compliant, cloud-ready business apps, services, and extensions on SAP BTP, SAP
S/4HANA Cloud, and SAP S/4HANA. RAP is the heart of ABAP Cloud for building
transactional SAP Fiori apps, OData-based services, and extensions.
RAP emcompasses a suite of concepts, tools, languages, and robust frameworks
that helps developers in building innovative, cloud-ready SAP Fiori applications as
well as local and Web APIs. It also support the extension of SAP S/4HANA
standard applications in both cloud and on-premise deployments.
RAP provides a standardized development flow leveraging ABAP Core Data
Services (CDS), the extended ABAP language, and business services within the
modern ABAP Development Tools for Eclipse (ADT).
Different types of services, local APIs, and business events can be developed and
modeled with RAP:
 OData-based services for UI development to build delightful, role-based,
responsive, and draft-enabled SAP Fiori apps
 OData-based services for exposure as Web APIs
 Lifecycle-stable and upgrade-safe local APIs can be provided via released
RAP business objects interfaces
 Business events that can be used for asynchronous communication to
notify a consumer that a RAP BO has changed
Built-in options for testability, supportability, documentability, and extensibility
such as ABAP unit tests, the ABAP cross trace tool, and knowledge transfer
documents are provided along the RAP development stack.
A seamless integration of reuse components such as business events and change
documents in the RAP framework is offered to lower the total cost of
development. Developers can for instance easily enable the exposure of business
events and allow the creation of change documents within RAP based
applications.
SAP uses ABAP RAP to build new standard business applications and
to modernize existing ones, and recommends it to its customers and partners for
their own custom developments.
Learn more: Evolution of the ABAP Programming | Modernization with RAP
What is a business object?
Common term to represent a real-world business entity – such as Product, Travel,
or SalesOrder – in enterprise application development.
On a conceptual level, a business object (BO) consists of a data model, aka
composition model, and its transactional behavior. In general, a business object
contains:
 several nodes, for example, the root node SalesOrder and the child
nodes SalesOrderItems and ScheduleLine
 standard transactional operations for creating, updating, and deleting
business data
 non-standard, application-specific transactional operations
RAP offers different runtime implementation types for the implementation of the
transactional business objects' behavior. The main ones are the managed BO
runtime implementations and the unmanaged BO runtime implementations –
typically used for greenfield and brownfield implementations respectively.
What is a query?
A query is the connecting interface for read-only access to the database in OData
services. It is used for list reports or analytical reports to process data.
As the non-transactional counterpart of a business object, it consists of a data
model, generic and modeled query capabilities and a runtime. This threefold
division is known from the BO concept. However, a query provides only read
access to the database. Its runtime never modifies data, but only executes
structured data retrieval, for example for filtering.
What is a business service?
The ABAP development platform can act in the roles of aservice providerand
aservice consumer(such as SAP Fiori UI client).
In the context of the ABAP RESTful application programming model, a business
service is a RESTful service which can be called by a consumer. It is defined by
exposing its data model together with the associated behavior. It consists of a
service definition and a service binding.
What is a business event?
RAP natively supports event-driven architecture. RAP business events provide the
solution to natively incorporate asynchronous communication into the RAP
architecture. They allow developers to trigger follow-up processes for significant
changes to a RAP business object.
Business events are defined and can be consumed with a RAP BO: As event
provider, a developer defines an event in the behavior definition and raises it in
the behavior implementation. The raised event can then be consumed locally in
the same system using a local event handler class or remotely in another system
using the SAP Event Mesh on SAP BTP. The latter consumption scenario requiring
the creation of an event binding that maps the event to a namespace, a business
object, and a business object operation. A RAP BO can consume such released
events with an event consumption model that establishes the design-time
consumption of an event from the SAP Event Mesh.
Data modeling
ABAP Core Data Services (CDS) offers a data modelling infrastructure for
defining semantically rich data models and easy access to advanced SAP HANA
libraries and features using CDS table functions. The data definition language of
ABAP CDS has been enhanced to natively support the definition of composition
and behavior models of RAP BOs.
ABAP language
ABAP LANGUAGE
The ABAP language has gone through various evolutions since its inception. Its
recent modernization – with a focus on simplification – has turned it into a more
declarative and expression-oriented language, which allows developers to write
more simple and concise ABAP code using language features such as inline
declarations with type inference, new operation constructors, and filtering,
grouping and virtual sorting operations for internal tables. The ABAP language
has also been extended with the Entity Manipulation Language (EML), which is
used to control the transactional behavior of RAP BOs.
ENTITY MANIPULATION LANGUAGE
EML offers an SQL-like syntax that allows developers to implement the
transactional behavior of RAP business objects. It also offers a type-safe, API-
based access to RAP BOs within and outside the RAP context.
ABAP DEVELOPMENT TOOLS FOR ECLIPSE
The ABAP Development Tools (ADT) is the integrated development
environment on the well-known Eclipse platform for all standard ABAP
development, quality assurance, and supportability tasks, both on on-premise
and on cloud ABAP systems.
ADT offers a modern development toolset with many goodies such as syntax
highlighting, code completion, code templates, advanced search and navigation,
and quick fixes to increase developer productivity. Various eclipse-based editors,
views, and features are provided. For instance, the Relation Explorer view is
provided to explore the structure and capabilities of development objects such as
RAP BOs. The ADT wizard Generate ABAP Repository Objects can be used to
generate all required RAP artefacts for an OData service with managed
implementation type based on a database table.
Moreover, powerful options and tools for testability and troubleshooting are
provided in ADT.
TESTABILITY
As an application developer, you want to verify the behavior of an application as
a whole by writing and executing unit, scenario, and integration tests.
The ABAP platform and ADT provide powerful frameworks and tools to ensure
high quality applications throughout the software development lifecycle. These
include the ABAP Test Cockpit for performing static checks, the ABAP Unit test
framework for testing, various Test Doubles Frameworks – e.g., for ABAP, SQL,
CDS, and RAP business objects – for isolating the code under test, and the
local OData client proxy for the API-based testing of OData services.
TROUBLESHOOTING
As an application developer, you want to be able to search for the origin of
occurring semantic, functional, and performance issues and fix them.
ADT supports you in this by offer several advanced analysis and troubleshooting
options and tools in the form of ADT views, for instance:
 ABAP Debugger – used for troubleshooting the business logic implement in
the backend.
 ABAP Cross Trace – used for a semantic end-to-end analysis of OData-
based services or business objects built with RAP.
 ABAP Profiling – used for analyzing the runtime behavior of an ABAP
program.
 Various ABAP CDS Tools – used to define and analyze CDS-based data
models.

ABAP RESTful Application Programming


Model
The ABAP RESTful Application Programming Model (in short RAP) defines the architecture
for efficient end-to-end development of intrinsically SAP HANA-optimized OData services
(such as Fiori apps) in ABAP Cloud. RAP supports the development of all types of
transactional Fiori applications as well as publishing Web APIs. It is based on technologies
and frameworks such as Core Data Services (CDS) for defining semantically rich data
models and a service model infrastructure for creating OData services with bindings to an
OData protocol and ABAP-based application services for custom logic and SAPUI5-based
user interfaces – as shown in the figure below.

More information on how RAP relates to ABAP Cloud and on its role in the ABAP Cloud
development model is available in the ABAP Cloud concepts guide.
Architecture Overview

Classification of ABAP RESTful Application Programming Model within


the Evolution of ABAP Programming Model
This image is interactive. Hover over each area for a description. Click
highlighted areas for more information.

 For more information about the evolution of the ABAP programming model,
read this blog on the community portal.
RAP in Simple Terms
The RESTful Application Programming model is part of ABAP Cloud. ABAP Cloud
consists of different documentation sets for the different use cases. The following
graphics give you an overview of all available guides for the different scenarios.
To get more an overview of ABAP Cloud, see ABAP Cloud Development Model.
This guide describes the ABAP RESTful application programming model (RAP)
that you use to build transactional apps in ABAP Cloud. RAP deals with how data
and the related business logic are modeled to implement transactional OData
services for SAP Fiori apps or Web APIs.
The data model, describing different entities involved in a business scenario like,
for example, Travel, is defined and arranged using ABAP Core Data Services
(CDS). These CDS entities are the building blocks of your application and
represent real-world entities. In RAP, the CDS entities model a so called business
object that consists of the data model, the defined behavior, and the
corresponding runtime implementation for the behavior. The behavior part of
RAP defines what actions can be performed with the data, like updating or
deleting it.

You might also like