ABAP Restful Application Programming Model 1738516139
ABAP Restful Application Programming Model 1738516139
Programming Model
Part-4
9/2/2024
Input
The following table de nes which components are imported into the function handler method.
Output
The following table summarizes the provider rules for the function implementation.
Successful function operation. If the function has a result Existing instance identi ers on result
parameter, the implementation instance functions.
lls the response parameter
Distinct content identi ers of
result. For every output
static functions.
parameter instance, it lists the
input identi er and the
calculated function result in
%param.
Unsuccessful function Implementation returns one row Non-existing instance identi er failed
operation. for each failed input identi er in for instance functions. (Fail
failed. It lists the input cause not_found.)
identi er with the correct fail
Unauthorized for function
cause and ags the %action
operation. This is only
component on the correct
applicable if authorization is
function. (Duplicates may
implemented in modify
appear)
handlers in an unmanaged BO.
For every input identi er listed (Fail cause unauthorized.)
in failed with fail cause other
Feature-control disabled
than not_found, there is one
operation. This is only
related error message returned
applicable if feature control is
in reported.
implemented in modify
handlers in an unmanaged BO.
(Fail cause disabled.)
Feature control is used to return permission values for operation, eld, action and function control. Depending on the
permission value a RAP consumer is allowed to execute an operation, action or function, or change a eld on the transactional
buffer of a RAP BO.
The implementation is done in the ABAP behavior pool in the method FOR FEATURES and method FOR GLOBAL
FEATURES, see FOR INSTANCE FEATURES, FEATURES (ABAP Keyword Documentation) and FOR GLOBAL FEATURES (ABAP
This is custom documentation. For more information, please visit the SAP Help Portal 151
9/2/2024
Keyword Documentation).
A BO consumer triggers the feature control with an ABAP EML get permissions request. The BO consumer expects that the
feature control implementation returns the requested permission values for existing instance identi ers.
Input
The following list de nes which components are imported into the feature control handler method.
Requested features
Output
The following table summarizes the provider rules for the feature control implementation.
Successful instance feature Implementation returns exactly Existing instance identi ers. result
control. one row for each existing
Duplicate existing instance
instance identi er in result. It
identi ers.
lists the input identi er and the
feature control permission
values.
This is custom documentation. For more information, please visit the SAP Help Portal 152
9/2/2024
Unsuccessful feature control. For instance feature control, the Non-existing (duplicate) failed
implementation returns one row instance identi ers. (Fail cause
for each failed instance not_found.)
identi er in failed. It lists the
source instance identi ers with
the correct fail cause and initial
%op. (Duplicates may appear.)
Authorization control is implemented in RAP BOs to manage authorizations for executing a standard operation, an action or a
function. The authorization can either be based on the status of a BO instance (instance authorization), or it can be instance-
independent (global authorization).
The implementation is done in the ABAP behavior pool in the method FOR INSTANCE AUTHORIZATION and method FOR
GLOBAL AUTHORIZATION, see Authorization Control.
A BO consumer triggers authorization control with an ABAP EML get permissions request. The BO consumer expects that the
authorization handler methods return the requested permission values for existing instance identi ers in case of instance
authorization, or permission values that are valid globally.
Input
The following list de nes which components are imported into the authorization control handler method.
Requested features
Output
The following table summarizes the provider rules for the authorization control implementation.
This is custom documentation. For more information, please visit the SAP Help Portal 153
9/2/2024
Authorization Control Implementation Specific Rules
Successful instance Implementation returns exactly Existing instance identi ers. result
authorization control. one row for each existing
Duplicate existing instance
instance identi er in result. It
identi ers.
lists the input identi er and the
authorization control permission
values.
Strict Mode
The strict mode ensures that a RAP business object is lifycycle-stable and upgrade-save.
Note
It is best practice to use strict(2) for all RAP BOs, except for:
CL_EXCHANGE_RATES
CL_NUMBERRANGE_INTERVALS
CL_UOM_DIM_MAINTENANCE
This is custom documentation. For more information, please visit the SAP Help Portal 154
9/2/2024
CL_UOM_MAINTENANCE
The strict mode represents the best practices regarding modeling and implementing a RAP business object. When a BO is
de ned as strict, this set of best-practice rules is technically enforced with additional syntax checks on speci c design and
implementation requirements to make sure that a BO is lifecycle-stable, upgrade-safe, and best-practice compliant.
Strict mode exists in different versions. It's recommended to always use the hightest version to ensure the strictest checks are
applied to your RAP BO. The highest version always applies all checks of the previous versions and additional own checks.
When strict mode is de ned, some syntax checks that lead to warnings without strict mode then lead to runtime errors.
RAP best practices are enforced, like, for example, authorization implementation is mandatory.
Strict mode is currently mandatory and a prerequisite for BOs that are released with a release contract. For more information
strict mode implementation requirements, refer to Strict Mode - Implementation Requirements for an overview.
De nition
You enable the strict mode with the addition strict directly after the implementation type in the behavior de nition. The
strict mode is available for the implementation types managedand unmanaged. For more information about strict, see CDS
BDL - strict (ABAP Keyword Documentation).
Requirement: Indicates the best practice implementation expected by the strict mode
Implementation Type: Indicates for which implementation type a corresponding requirement is valid.
Strict Mode Version: Indicates whether an implementation requirement result from strict or strict(2)
Affects: Indicates which RAP artifact is affected by errors once strict and additional syntax checks are active.
More Information: Links to further information in the documentation (column can be added with Switch/Hide Column).
This is custom documentation. For more information, please visit the SAP Help Portal 155
9/2/2024
This is custom documentation. For more information, please visit the SAP Help Portal 156
9/2/2024
Note
Projection BDEFs can't be
based on abstract base
behavior de nitions.
Implement the
Managed Strict mode Base Behavior ADJUST_NUMBERS
ADJUST_NUMBERS method
version 1: De nition Nodes
in the behavior pool, if you've Unmanaged strict
de ned late numbering.
This is custom documentation. For more information, please visit the SAP Help Portal 157
9/2/2024
This is custom documentation. For more information, please visit the SAP Help Portal 158
9/2/2024
draft determine
action Prepare { }
Unmanaged
(only if draft-
enabled)
De ne functions as FOR
Managed Strict mode Base Behavior
FUNCTION in the method
version 1: Implementation
de nition of your behavior Unmanaged strict
implementation. Projection
Behavior
Note Implementation
The de nition FOR
ACTION for a function
results in a syntax error.
This is custom documentation. For more information, please visit the SAP Help Portal 159
9/2/2024
De ne an
implementation in Managed Strict mode Base Behavior
class version 1: De nition
Unmanaged strict
*ImplementationClass*
Projection
unique for each BO node Behavior
where an implementation is De nition
required.
This is custom documentation. For more information, please visit the SAP Help Portal 160
9/2/2024
This is custom documentation. For more information, please visit the SAP Help Portal 161
9/2/2024
Feature Control
Standard or Non-
Standard Operations
Locks
Etag handling
Foreign Entity
...
Related Information
Strict Mode
From a technical perspective, a BO interface layer consists of a CDS projection view with the provider contract
transactional_interface and a Behavior Definition Interface with the keyword interface in its header. A
RAP BO interface is a speci c BDEF type without a runtime handler and thus without implementation class and behavior pool,
that speci es a subset of elements from a RAP base BO.
The interface layer is built on top of the base BO layer as single point of access to the base BO:
This is custom documentation. For more information, please visit the SAP Help Portal 162
9/2/2024
Each RAP base BO can have multiple interfaces ([0,*]) to comply with different consumer requirements and use cases, for
example one BO interface that exposes draft capabilities and another interface with the same RAP base BO that doesn't
expose the draft capabilities and only allows access to active instances.
For more information about the syntax, refer to CDS DDL - DEFINE VIEW ENTITY AS PROJECTION ON, Transactional Interface
and for more information about the provider contract, refer to CDS DDL - PROVIDER CONTRACT transactional_interface (ABAP
Keyword Documentation).
Since a RAP BO interface only acts as a consolidated consumption view for a RAP base BO, it doesn't have its own runtime
handler. So, all incoming requests are delegated to the underlying RAP base BO and its respective behavior pool and
implementation.
You can only newly de ne or rede ne static feature control on the interface layer for elements from the RAP base BO. For
example, you can de ne a elds as readonly in a BO interface when the same eld doesn't have any static feature control in
the underlying base BO. Other than static feature control, it's not possible to introduce new behavior or change existing
behavior on interface level.
For an example about how to implement RAP BO interfaces, refer to Develop APIs.
This is custom documentation. For more information, please visit the SAP Help Portal 163
9/2/2024
An overview of the consumption possibilites of business objects and their interfaces can be found in chapter Consume.
The layer beneath a released SAP interface can't be accessed or consumed directly, but must always be accessed via the
released interface layer of the RAP base BO.
A BDEF extension is always based on a Business Object Interface (BO Interface) through which the implementation of
the original RAP BO is accessed. A BDEF extension to the original BO technically extends the base BDEF, but is consumed via
the BO interface during the runtime.
Annotation propagation
The interface projection layer is used to decouple requirements for the stable consumption of a business object from its
underlying base data model and behavior. With respect to annotations, this means that annotation changes in the base data
model must have no impact on the data model in the interface projection layer and above. Hence it is best practice to use the
annotation @Metadata.ignorePropagatedAnnotations: true in the header section of the interface projection view.
This annotation prevents annotations from the underlying base data model from being propagated further through the CDS
view stack, thus possibly impacting projections that are built on top of the RAP BO interface. The annotations that are supposed
to be effective in superjacent projections should be de ned explicitly in the interface projection view.
Business Service
De nition
The ABAP development platform can act in the roles of a service provider and a service 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 de ned by exposing its data model together with the associated behavior. It consists of a service de nition
and a service binding.
This is custom documentation. For more information, please visit the SAP Help Portal 164
9/2/2024
Business Service
A business object (BO) is a common term used to represent a real-world artifact in enterprise application development such as
the Product, the SalesOrder or the Travel. In general, a business object contains multiple nodes such as Items and
ScheduleLines (data model) and common transactional operations such as creating, updating and deleting data and additional
application-speci c operations, such as the Approve action in a SalesOrder business object. All modifying operations for all
related business objects form the transactional behavior model of an application.
Example
Let us assume that a business object SalesOrder is de ned and implemented in the data model and the behavior layer with the
related value help and authorization management. The service de nition might expose the SalesOrder and several additional
business objects such as the Product and the BusinessPartner as they are included in a service binding for an OData V2 service.
The service de nition and the related projection views that project the service relevant parts of the data model
implemented in CDS and the behavior de nition where it projects the operations that should be exposed. For example,
the SalesOrder BO might offer the operations: create, update, delete, and 10 different application-speci c actions.
However, for a concrete role-speci c list report, only two actions are required, so the remaining 8 actions and three
standard operations are not included in the service projection.
If the service is used to create a user interface, additional UI semantics are required. These are implemented by CDS UI
annotations that are regularly stored in CDS metadata extensions (MDEs).
The service binding that uses the package of artifacts that is de ned in the service de nition to bind the package to a
service type (Web API, UI service, INA service) and a protocol type (OData V2, OData V4).
Related Information
This is custom documentation. For more information, please visit the SAP Help Portal 165
9/2/2024
Service De nition
Service Binding
Working with Business Services
Introduction
A service projection layer is required for a exible service consumption of one business object. The basic business object is
service agnostic. That means, this BO is built independently from any OData service application. The basic BO comprises the
maximum range of features that can be applicable by a service that exposes this BO. The projection layer is the rst layer in the
development ow of the ABAP RESTful Programming Model that is service speci c. When projecting the basic BO, you de ne
the real manifestation of a business object in an OData service. The business object projection entails that part (the subset) of
the BO structure and behavior that is relevant for the respective service, including denormalization of the underlying data
model. Furthermore, the projection layer contains service-speci c ne-tuning which does not belong to the general data model
layer, for example UI annotations, value helps, calculations or defaulting.
The projection layer also enables one business object to be exposed in an OData service for a Fiori UI and for a stable Web API.
The service-speci c differences can then be implemented in the respective projection layers. For example, UI speci cations are
de ned only in the BO projection that is exposed for the UI service. Furthermore, with projections, you cannot only de ne the
type of the service, but you can also design role-based services. One business object for general purpose is exposed for more
than one context-speci c projection as specialized business object. The most prominent example is the business partner BO,
which is exposed as customer, vendor, or supplier. In the projection, you can use that subset of the business partner BO that is
relevant for the respective specialization.
Example
The basic BO of a business partner contains a wide range of CDS elements and behavior options. Depending on the concrete
realization of the business partner, that is, depending on which role the business partner is assigned to, the structure of the
data model and the behavior in the BO projection might vary. In the role of a customer, which is a typical projection of the
business partner, the business partner projection contains the standard data available for business partners and in addition,
sales arrangements. Sales arrangements contain data that is related to speci c sales areas and used for the purposes of
sales. All these characteristics must already be available in the basic BO and are then selected as a subset of the general
business partner pool of elements and functionalities.
Imagine the business partner is enriched with characteristics for a new role of a business partner, for example a supplier. You
can add the necessary additional elements, for example delivery information, to the data model and the behavior
implementation in the business partner BO without affecting the already existing BO projections.
This is custom documentation. For more information, please visit the SAP Help Portal 166
9/2/2024
To create a projection layer for a business object, you need to create two projection artifacts:
This is custom documentation. For more information, please visit the SAP Help Portal 167
9/2/2024
CDS Projection Views
The projection of the data model is done in one or more CDS projection views, depending on the number of nodes of the
underlying BO. The CDS projection views use the syntax element as projection on <ProjectedEntity> to mark
the relationship to the underlying projected entity. As opposed to the former consumption views, they do not create
another SQL view. Since they only provide the consumption representation of the projected entity, they do not need an
ABAP Dictionary representation.
If one BO entity is projected, the root and all parent entities must be projected as well. The root entity has to stay the
root entity and must be de ned as root projection view. The compositions are redirected to the new target projection
entity.
Travel BO Projection
For a detailed description on CDS projection views and their syntax, see CDS Projection View.
The projection of the behavior is done in a behavior de nition of type projection, which is declared in the header of
the behavior de nition. According to this type, only syntactical elements for projections can be used.
For more information on projection behavior de nitions and their syntax, see Projection Behavior De nition.
CDS projection views are de ned in data de nition development objects. The wizard for data de nitions provides a template for
projection views.
For the CDS view projection, a subset of the CDS elements is projected in the projection view. These elements can be aliased,
whereas the mapping is automatically done. That means, the elements can be renamed to match the business service context
of the respective projection. It is not possible to add new persistent data elements in the projection views. Only the elements,
that are de ned in the underlying data model can be reused in the projection. However, it is possible to add virtual elements to
projection views. These elements must be calculated by ABAP logic.
You can add new read-only associations in the projection view. This can be relevant to display additional information on the UI,
like charts etc. It is not possible, however, to denormalize elds from new associated entity in the projection view. New
associated entities cannot be accessed transactionally. Associations, including compositions, that are de ned in the projected
This is custom documentation. For more information, please visit the SAP Help Portal 168
9/2/2024
CDS view can be used in the projection CDS view. However, associations or compositions might change their target, if the target
CDS view is also projected. This is especially relevant for compositions as the complete Data Model is projected and therefore
the composition target changes. In case of a changed target, the association or composition must be redirected to the new
target. The projection view comes with a new syntax element to express the target change.
For more details about the projection view syntax, see De ne View Entity as Projection (ABAP Keyword Documentation).
If you use an annotation with an element reference in the projected entity and the reference element is aliased in the projection
entity, the reference is not drawn to the element in the projection view, due to the name change. In such a case, you have to
rede ne the annotation in the projection view and use the alias name of the element in the annotation value.
Example
The amount and currency elements are annotated in the underlying CDS view with @Semantics annotations to support the
semantic relationship of the elements.
{
key travel_id,
...
@Semantics.amount.currencyCode: 'currency_code'
total_price,
@Semantics.currencyCode: true
currency_code,
...}
Both @Semantics annotations are propagated to the projection view. However, the element currency_code is aliased in
the projection view and therefore the reference to the correct element is not established. Hence, the relationship is broken
and the metadata of a possible OData service will not resemble this semantic relationship.
To avoid this, you have to reannotate the amount element with the reference to the aliased element.
{
key travel_id,
...
@Semantics.amount.currencyCode: 'CurrencyCode'
total_price as TotalPrice,
currency_code as CurrencyCode,
...}
This is custom documentation. For more information, please visit the SAP Help Portal 169
9/2/2024
Search Enablement
Value Helps
Restriction
In the current version of the ABAP RESTful Programming Model, CDS projection views can only be used to project CDS view
entities. Other entities, such as custom entities are not supported.
Related Information
Providing a Data Model for Projections
The behavior de nition with type projection is created equally to other types of behavior de nitions. When creating a
behavior de nition based on a CDS projection view, the syntax template directly uses the projection type.
In a behavior de nition, only behavior characteristics and operations that are de ned in the underlying behavior de nition can
be de ned for the BO projection. The syntax for this is use <Element>.
For details about the syntax of a projection behavior de nition, see CDS BDL - implementation type (ABAP Keyword
Documentation).
Explanation
The keyword use exposes the following characteristics or operations for the service-speci c projection. In the projection, only
elements can be used that were de ned in the underlying behavior de nition. These elements can be
ETag
standard operations
actions
functions
create_by_association
Every operation that you want to expose to your service must be listed in the projection behavior de nition. New aliases can be
assigned for actions and functions. Projection behavior de nitions do not have a behavior implementation. The complete
behavior is realized by mapping it to the underlying behavior.
This is custom documentation. For more information, please visit the SAP Help Portal 170
9/2/2024
The de nitions that already restrict the character of the underlying BO are automatically applied in the BO projection and
cannot be overwritten. This is the case for:
locking
authorization
feature Control
If no static eld control is de ned in the underlying behavior de nition, you can add this de nition in the projection behavior
de nition. If it is already de ned in the underlying behavior de nition, you cannot de ne the opposite in the projection layer. If
you do, you will get an error during runtime. New dynamic eld control cannot be de ned in the projection behavior de nition, as
there is no option to implement the feature.
Related Information
Providing Behavior for Projections
Service De nition
De nition
A business service de nition (short form: service de nition) describes which CDS entities of a data model are to be exposed so
that a speci c business service, for example, Sales Order handling, can be enabled. It is an ABAP Repository object that
describes the consumer-speci c but protocol-agnostic perspective on a data model. It can directly access the standard ABAP
Workbench functionality, such as transports, syntax checks, element information, and activation. Its transport type is SRVD.
Use
A service de nition represents the service model that is generically derived from the underlying CDS-based data model.
You use a service de nition to de ne which data is to be exposed as a business service using one or more service bindings. A
service de nition itself is independent from the version or type of the protocol that is used for the business service.
Remember
When going to expose a data model as a service, you use of a service de nition only in connection with at least one service
binding.
Note
You cannot expose an OData service that includes abstract entities for Web APIs or UI services. You can expose abstract
entities in a service de nition, but only if they are created using OData client proxy tools (service consumption use case).
The publishing of a service via a service binding causes a dump error.
For details about the syntax to de ne a service, see CDS SDL - DEFINE SERVICE (ABAP Keyword Documentation)
Explanation
The source code of the actual service de nition is preceded by the optional CDS annotation @EndUserText.label that is
available for all objects which can contain CDS annotations. The annotation value is a character string with a maximum of 60
characters. The speci ed text value should consist of a meaningful short text that describes the service in the original
language of the source code.
This is custom documentation. For more information, please visit the SAP Help Portal 171
9/2/2024
Depending on the needs of your scenario, further optional annotations @<Annotation_1> ... @<Annotation_n> can be
speci ed. If you expose a complete business object structure with more than one CDS entity for a service you can use the
annotation @ObjectModel.leadingEntity.name: to de ne the root entity of the business service and hence the primary
entrance point to the business service. The annotation provokes that the entity is marked in the entity tree in the service
binding editor and appears as the rst entity in the list.
The service de nition is initiated with the DEFINE SERVICE keyword followed by the name for the service de nition.
The source code of a service de nition is created within a single bracket { ... } that is used to group all the related CDS entities
(including their associations with the relevant entities) which are to be exposed as part of an individual service.
The name of each individual CDS entity to be exposed follows the EXPOSE keyword. This is followed by an optional alias name,
which is initiated by the AS keyword. An alias de nes an alternative name for a CDS entity to be exposed. As a result, when
accessing the service, the alias names are used instead of the current entity names. Thus, you have the option of assigning
syntactically uniform identi ers in the service de nition and thus decoupling the service semantics from the concrete technical
names resulting from the data de nition.
Example
/DMO/Travel, de nes associations to the entities /DMO/Customer and /DMO/Agency. In addition, associations to the
entities I_Currency and I_Country must be included.
The following example shows the corresponding source code for the service de nition /DMO/TRAVEL. The travel management
service to be de ned in this way includes all dependencies that come from the root entity /DMO/I_TRAVEL.
This is custom documentation. For more information, please visit the SAP Help Portal 172
9/2/2024
Note
In this example, the service de nition is based on CDS entities that originate from different namespaces.
Related Information
Service Binding
Creating Service De nitions
A Service Definition Extension contains extension nodes you want to expose in your service binding. If you add a new
extension BO node to a RAP BO, you must extend an existing Service Definition to expose the new BO entity to the
consumer in the service binding. For more information about creating an extension node, see Node Extensions.
Service Binding
De nition
The business service binding (short form: service binding) is an ABAP Repository object used to bind a service de nition to a
client-server communication protocol such as OData. Like any other repository object, the service binding uses the proven
infrastructure of the ABAP Workbench, including the transport functionality.
Use
As shown in the gure below, a service binding relies directly on a service de nition that is derived from the underlying CDS-
based data model. Based on an individual service de nition, a plurality of service bindings can be created. The separation
between the service de nition and the service binding enables a service to integrate a variety of service protocols without any
kind of re-implementation. The services implemented in this way are based on a separation of the service protocol from the
actual business logic.
Relationship Between the Data Model, the Service Definition and the Service Binding
Parameters
The following parameters are used to characterize a service binding:
Service Name
De nes a unique system-wide name for the service and is identical to the name of the service binding.
Tip
We recommend using the pre x API_ for Web API services and the pre x UI_ for UI services.
This is custom documentation. For more information, please visit the SAP Help Portal 173
9/2/2024
Binding Type
The binding type speci es the service type and the speci c protocol which is implemented with the service binding.
The CDS data models can be exposed with the following protocols:
For more information about Fiori Elements apps based on OData V2 Models, see OData V2 Model.
Note
In OData V2 services, unit and currency types are automatically added to the service metadata as built-in entity sets.
With this feature, unit and currency values are always displayed correctly and validated regarding decimals on a UI.
OData V4 services have a wider scope than OData V2 services. Use OData V4 wherever possible for transactional
services.
Note
Full support for Fiori Elements UIs based on OData V4 services is only granted for draft-enabled scenarios.
For more information about Fiori Elements app based on OData V4 Models, OData V4 Model.
Analytical data models are exposed with InA for live data access.
SQL
Remember
The Open Data Protocol (OData) enables the creation of HTTP-based services, which allow resources identi ed using
Uniform Resource Identi ers (URIs) and de ned in an abstract data model to be published and edited by Web clients using
HTTP messages. OData is used to expose and access information from a variety of sources including, but not limited to,
relational databases, le systems, content management systems, and traditional Web sites.
This parameter also determines the way a service is offered to a consumer. There are two options:
UI UI service
A UI service makes it possible to add a SAP Fiori elements UI or other UI clients to the service.
A service that is exposed as Web API is used for all other use cases apart from UIs. Web APIs can be
consumed by an unknown consumer via OData. Web APIs can be extended.
Currently, Web APIs are supported for OData and SQL services.
This is custom documentation. For more information, please visit the SAP Help Portal 174
9/2/2024
Service Version
The versioning of services is made by a version number which is assigned to a service binding.
The next higher version is created by adding another service de nition to the existing service binding. By means of this further
service de nition, functional changes or extensions (compared to the previous version) are exposed. And, vice versa, the version
number can be decreased by removing a service de nition from the service binding.
Publishing
The local service endpoint of an OData service must be published via the Publish button in the service binding editor. This
triggers several task lists to enable the service for consumption. By publishing the service binding the service is only enabled for
the current system. It is not consumable from other systems.
Note
The service binding needs to be active to be published. To activate the service binding use the activation button in the tool
bar.
Service URL
The derived URL (as a part of the service URL) is used to access the OData service starting from the current ABAP system. It
speci es the virtual directory of the service by following the syntax: /sap/opu/odata/<service_binding_name>
Preview
You can start a Fiori Elements Preview directly from the service binding. With this, you can test UI-related features directly from
your ABAP system.
Release for contracts C2 possible in ADT Service Binding context C1 possible in ADT Service Binding context
menu API state . See also: Releasing menu API state . See also: Releasing
Development Objects Development Objects
Code lists for units of Not available Contained in service Contained in entity sets Contained in service
measure / currencies group SAP__Currency and group
SAP__UnitOfMeasure
This is custom documentation. For more information, please visit the SAP Help Portal 175
9/2/2024
ISO conversion of unit of Conversion disabled for ISO / SAP Unit validation Conversion disabled for ISO / SAP Unit validation
measure SAP Unit SAP Unit
Conversion Exit CUNIT Removed for the ISO unit of measure property Available
More information as well as examples for the business service exposure of business objects is available in the section Develop.
Service Transport
In an on-premise system, you can only use the service binding to enable your service locally and test it in the development
system. Transporting the service binding with all the related artifacts that are generated locally is not possible. To enable your
business service in a quali cation or productive system, you have to disable the service in your local system (Unpublish button).
Then use Gateway tools to activate and maintain your service.
For more information, see Activate the Service (SAP Gateway Foundation) for OData V2 scenarios or Service Development in
Hub System (V4) for OData V4 scenarios.
Service Errors
The service binding shows errors that are related to the complete service. They are shown on creating the service binding or
when reopening the artifact in ADT. The errors that are shown in the service binding are also appear in ATC checks.
Related Information
Service De nition
The following list of reuse data elements can be used for the administrative elds in RAP BOs of all implementation types. These
data elements are available for reuse in all systems.
ABP_LASTCHANGE_USER Identi er of the user who changed the local instance itself or its
compositional subtree last time.
ABP_LASTCHANGE_DATE Date on which the data of the local instance or its compositional
subtree was last changed.
This is custom documentation. For more information, please visit the SAP Help Portal 176
9/2/2024
ABP_LASTCHANGE_TIME Time at which the data of the local instance or its compositional
subtree was last changed.
ABP_LOCINST_LASTCHANGE_USER Identi er of the user who changed the local instance itself (without
considering its compositional subtree) last time.
ABP_LOCINST_LASTCHANGE_DATE Date on which the data of the local instance itself (without
considering its compositional subtree) was last changed.
ABP_LOCINST_LASTCHANGE_TIME Time at which the data of the local instance itself (without
considering its compositional subtree) was last changed.
ABP_LOCINST_LASTCHANGE_TSTMPL Timestamp at which the data of the local instance itself (without
considering its compositional subtree) was last changed.
ABP_LOCINST_LASTCHANGE_UTCL Timestamp at which the data of the local instance itself (without
considering its compositional subtree) was last changed.
Administrative data elds are relevant in RAP application to log data access and modi cation. This is especially important when
working with an OData ETag for optimistic concurrency control, or for the total ETag in draft applications.
For more information about the OData ETag, see Optimistic Concurrency Control.
For more information about the total ETag, see Total ETag.
Example
When creating a new instance, the RAP handler method for create must ensure that the elds for the creation user and the
creation time are lled correctly.
Use Case
This is custom documentation. For more information, please visit the SAP Help Portal 177
9/2/2024
Generally, the implementation of business object entity's operations and actions is done in the Local Types include of the
behavior pool (ABAP class that implements business object’s behavior) associated with that entity – unless the control of the
implementation classes using the IMPLEMENTATION IN CLASS syntax (at entity level) has been completely dispensed.
Since the Local Types include can only be changed by one developer at a time, the efficiency of development would be
signi cantly reduced in case of larger implementations. Let us think about large business objects with extensive business logic
implementations, with many entities, each of which may contain a variety of elements.
As a solution, the operations and actions of an entity can be divided into several groups, whereby each of these groups can then
be assigned a different behavior pool as implementation class.
Especially in large development projects, the responsibilities for the implementation of application logic are assigned to
different members of a development team. To support this approach technically, we introduce the concept of groups. This
approach enables that a team of developers can implement parts of business logic independently from each other. In addition,
the group concept allows to tailor the functionality of business objects according to semantic considerations.
For details about the syntax for de ning groups for unmanaged business objects, see CDS BDL - implementation grouping
(ABAP Keyword Documentation)
// It is possible to assign the same behavior pool as the implementation class in different group
group groupName_3 implementation in class ABAP_CLASS_1 unique
{
// Implementation-relevant content of the entity
}
group ...
This is custom documentation. For more information, please visit the SAP Help Portal 178
9/2/2024
Explanatory Notes
(1) The group name is de ned locally within the entity’s behavior de nition and must not con ict with actions, determinations, or
validations of the same name.
(2) The implementation in class syntax can only be used on groups, but no longer on individual entity’s behavior
de nition itself. A group requires a behavior pool ABAP_CLASS_* and the addition of unique.
Note
With the addition implementation in class ABAP_ClASS in the header of the behavior de nition, you have the option
to implement the remaining functionality for all entities in a common behavior pool. For example, the save sequence for all
entities of a business object could be implemented in a single behavior pool ABAP_CLASS.
It is possible to specify the same behavior pool as the implementation class in different groups. In the syntax above, the
implementation-relevant content of groupName_1 and of groupName_3 must be implemented in ABAP_CLASS_1.
Actions
Note
In the case of unmanaged implementation type, the standard operations (CREATE, UPDATE, DELETE) as well as READ
and CREATE by association must be assigned to a group. In the managed case however, the standard operations (that are
implemented by the framework) and READ and CREATE for associations can be speci ed either inside or outside groups.
(4) Information on mapping (which is never relevant to implementation) must always be speci ed outside of groups.
(5) Implicit standard operations (de ned automatically and don't have to be explicitly speci ed) must be explicitly speci ed
within one and the same group in the unmanaged case (where they are implementation-relevant):
Examples
{
group travel_cud implementation in class /dmo/bp_travel_cud unique
{
field ( read only ) TravelID;
field ( mandatory ) AgencyID, CustomerID, BeginDate, EndDate;
field(features:instance) overall_status;
create;
update(features:instance);
This is custom documentation. For more information, please visit the SAP Help Portal 179
9/2/2024
delete;
}
}
This is custom documentation. For more information, please visit the SAP Help Portal 180
9/2/2024
association _Booking { create; }
}
}
Implementation-Related Aspects
This is custom documentation. For more information, please visit the SAP Help Portal 181
9/2/2024
(1) The name of the group and which operations are associated with this group do not matter to external users (and can
therefore be changed retrospectively by the developer). This means that external operations and actions are still accessed by
the usual syntax, in which only the name of the entity, the operation, and, if applicable, the action/determination/validation or
association plays a role, but not the name of the group.
However, there are exceptions: the name of the group is relevant for the implementation of instance-based feature control - the
corresponding implementations then control only those features that are associated with their respective group. (The
framework merges the information for the external consumers.) The corresponding syntax entity-group can only be used
within the implementation class associated with that group. Speci cally, the following declarations are concerned:
Note
This declaration can also be done in the public section of the implementation class to make the group-dependent type
public outside. Because it makes the changes to group assignment incompatible with external users, such publishing is not
recommended.
Within the implementation class, the syntax methods ... for features for instance-based feature control can only be
de ned by specifying the group name:
endclass.
(2) Because associations with the usual association syntax can only be assigned as a whole to a group, it is not possible to
implement the association's CREATE operation in an implementation class other than the READ operation.
method create_bookings.
This is custom documentation. For more information, please visit the SAP Help Portal 182
9/2/2024
...
endmethod.
method read_bookings.
...
endmethod.
endclass.
The following code block shows the travel database table without a client eld. The following example depicts a table for an
active instance, but the respective draft table has an identical structure and can only be differentiated by the table name.
This is custom documentation. For more information, please visit the SAP Help Portal 183
9/2/2024
automatically created draft tables are created client-independently. For more information about how to generate draft
database tables, refer to Draft Database Table.
In addition, the created SQL-view of a CDS V1 view must not contain such a client element. When using CDS V2, the client
handling of the CDS view is implicitly de ned by the underlying data source.
There must be client-consistency among the entities in the business object composition structure. You can't to have one entity
that is client-dependent and another one that is client-independent with a compositional relationship between them.
Note
In scenarios in which you have client-dependent database tables, but join client-independent elds from other database
tables to your CDS view, the managed BO runtime locks the instances speci c to the client. This means only the elds from
the client-dependent database tables are locked. If you also want to lock the client-independent elds, you have to
implement an unmanaged lock.
Note
In scenarios, in which you use an unmanaged save in the managed scenarios, the managed BO runtime always sets a client-
speci c lock. If you want to lock client-independently, you have to use an unmanaged lock.
Related Information
Lock De nition
Integrating Unmanaged Save in Managed Business Objects
For basic information on determinations and validations, see Determinations and Validations.
Trigger conditions
Determinations and validations are commonly used to rst read instance data and then to perform the modi cation/validation
based on the read data. In order to ensure, that the determinations and validations can react on changes in elds that are read
repectively, these elds should be used as their trigger conditions.
In order to implement determinations and validations kind independently, use the derived type component %tky. This
component includes the draft indicator %is_draft which is set depending on the context by the framework. Before you set the
draft indicator %is_draft manually, ensure that this does not lead to an unwanted difference in behavior between draft and
active instances.
This is custom documentation. For more information, please visit the SAP Help Portal 184
9/2/2024
For more information on the draft indicator, see Draft.
Determination usage
Application logic intended to notify about saved changes must be implemented in a provider implementation that is called after
the point of no return of the save sequence, e.g. in the additional save implementation. It must not be implemented in a
determination on save.
RAP BO Runtime
The runtime of a RAP business object (BO) consists of two main parts: The interaction phase and the save sequence.
Interaction Phase
The interaction phase is the rst part of the BO runtime. In this phase, a consumer can call business object operations to
change data and read instances with or without the transactional changes. The business object keeps the changes in its internal
transactional buffer, which represents the state. This transactional buffer is always required for a business object, regardless of
how it is implemented.
Save Sequence
When all changes are done, the data must be persisted. This happens in the second part of the BO runtime, the save sequence.
This image is interactive. Hover over each area for a description. Click highlighted areas for more information.
This is custom documentation. For more information, please visit the SAP Help Portal 185
9/2/2024
Please note that image maps are not interactive in PDF output.
Implementation
The implementation of the interaction phase and the save sequence is carried out in a special type of class pool, the behavior
pool, which refers to the behavior de nition. The interaction phase is represented by the local handler class and the save
sequence by the local saver class. For more information on the implementation of business object functionality, see also :
Business Object Provider API.
Operations Runtime
The RAP Transactional Model and the SAP LUW
This topic describes how RAP supports the transactional model of a controlled SAP LUW. The logical unit of work (LUW)
is the sum of all operations and work processes that are used to transfer data from one consistent state on the
database to another.
Save Sequence Runtime
The save sequence is part of the business object runtime and is called after at least one successful modi cation was
performed during the interaction phase.
Operations Runtime
This section describes the operations that are available for RAP business objects and their functionality.
Note
In case of a managed business object, instances for child entities can only be created by a create-by-association.
The following runtime diagram illustrates the main agents' activities during the interaction phase of a create operation when
the BO consumer sends a create request. The save sequence is illustrated in a separate diagram, see Save Sequence Runtime.
In general, the instantiation of handler and saver classes is tightly coupled to an ABAP session. Instances live as long as the
ABAP session and they can exist across LUW borders. However, their life cycle depends on the way their methods are called.
Nested method invocations always provoke the reinstantiation of the local handler and saver classes. For example, this is the
case if a handler method executes an EML modify request in local mode to call another method of the same handler class, or if
other BOs are involved in the invocation chain.
Note
Do not work with data in member variables for keeping data for subsequent method invocation. The data is lost once the
handler class is reinstantiated.
This is custom documentation. For more information, please visit the SAP Help Portal 187
9/2/2024
This is custom documentation. For more information, please visit the SAP Help Portal 188
9/2/2024
Please note that image maps are not interactive in PDF output.
Related Information
Update Operation Runtime
Delete Operation Runtime
Create by Association Operation Runtime
The following runtime diagram illustrates the main agents' activities during the interaction phase of an update operation when
a BO consumer sends an update request. The save sequence is illustrated in a separate diagram, see Save Sequence Runtime.
In general, the instantiation of handler and saver classes is tightly coupled to an ABAP session. Instances live as long as the
ABAP session and they can exist across LUW borders. However, their life cycle depends on the way their methods are called.
Nested method invocations always provoke the reinstantiation of the local handler and saver classes. For example, this is the
case if a handler method executes an EML modify request in local mode to call another method of the same handler class, or if
other BOs are involved in the invocation chain.
Note
Do not work with data in member variables for keeping data for subsequent method invocation. The data is lost once the
handler class is reinstantiated.
This is custom documentation. For more information, please visit the SAP Help Portal 189
9/2/2024
This is custom documentation. For more information, please visit the SAP Help Portal 190
9/2/2024
Please note that image maps are not interactive in PDF output.
This is custom documentation. For more information, please visit the SAP Help Portal 191
9/2/2024
Related Information
Create Operation Runtime
Delete Operation Runtime
Create by Association Operation Runtime
The following runtime diagram illustrates the main agents' activities during the interaction phase of a delete operation when a
BO consumer sends a delete request. The save sequence is illustrated in a separate diagram, see Save Sequence Runtime.
In general, the instantiation of handler and saver classes is tightly coupled to an ABAP session. Instances live as long as the
ABAP session and they can exist across LUW borders. However, their life cycle depends on the way their methods are called.
Nested method invocations always provoke the reinstantiation of the local handler and saver classes. For example, this is the
case if a handler method executes an EML modify request in local mode to call another method of the same handler class, or if
other BOs are involved in the invocation chain.
Note
Do not work with data in member variables for keeping data for subsequent method invocation. The data is lost once the
handler class is reinstantiated.
This is custom documentation. For more information, please visit the SAP Help Portal 192
9/2/2024
This is custom documentation. For more information, please visit the SAP Help Portal 193
9/2/2024
Please note that image maps are not interactive in PDF output.
Related Information
Create Operation Runtime
Update Operation Runtime
Create by Association Operation Runtime
The following runtime diagram illustrates the main agents' activities during the interaction phase of a create by
association operation when a BO consumer sends a create-by-association request. The save sequence is illustrated in a
separate diagram, see Save Sequence Runtime.
In general, the instantiation of handler and saver classes is tightly coupled to an ABAP session. Instances live as long as the
ABAP session and they can exist across LUW borders. However, their life cycle depends on the way their methods are called.
Nested method invocations always provoke the reinstantiation of the local handler and saver classes. For example, this is the
case if a handler method executes an EML modify request in local mode to call another method of the same handler class, or if
other BOs are involved in the invocation chain.
Note
This is custom documentation. For more information, please visit the SAP Help Portal 194
9/2/2024
Do not work with data in member variables for keeping data for subsequent method invocation. The data is lost once the
handler class is reinstantiated.
This is custom documentation. For more information, please visit the SAP Help Portal 195
9/2/2024
This is custom documentation. For more information, please visit the SAP Help Portal 196
9/2/2024
Please note that image maps are not interactive in PDF output.
Related Information
Create Operation Runtime
Update Operation Runtime
Delete Operation Runtime
Action Runtime
In RAP, an action is a non-standard modify operation.
Action Runtime
In RAP, an action is a non-standard modify operation.
The following runtime diagram illustrates the main agents' activities during the interaction phase of an action when a BO
consumer requests the execution of an action. The save sequence is illustrated in a separate diagram, see Save Sequence
Runtime.
In general, the instantiation of handler and saver classes is tightly coupled to an ABAP session. Instances live as long as the
ABAP session and they can exist across LUW borders. However, their life cycle depends on the way their methods are called.
Nested method invocations always provoke the reinstantiation of the local handler and saver classes. For example, this is the
case if a handler method executes an EML modify request in local mode to call another method of the same handler class, or if
other BOs are involved in the invocation chain.
Note
Do not work with data in member variables for keeping data for subsequent method invocation. The data is lost once the
handler class is reinstantiated.
This is custom documentation. For more information, please visit the SAP Help Portal 197
9/2/2024
This is custom documentation. For more information, please visit the SAP Help Portal 198
9/2/2024
Please note that image maps are not interactive in PDF output.
Related Information
Actions
Action De nition
Action Implementation
This is custom documentation. For more information, please visit the SAP Help Portal 199
9/2/2024
The ABAP RESTful Application Programming Model (RAP) does not introduce its own LUW concept, but uses the rules and
concepts of the SAP LUW. RAP strictly adheres to the rules of a SAP LUW by inherently checking transactional contexts and
only allowing developers to use or call implementations that match the transactional contexts. In that sense, the controlled
SAP LUW is inherently built into RAP. For more information about transactional consistency during the SAP LUW, see Controlled
SAP LUW.
To make sure that an application and all involved parties (for example other business objects) work consistently and aligned
with all LUW prerequisites, the transactional modeling of highly complex scenarios can become cumbersome and
unforeseeable. When developing with RAP, you achieve a consistent transactional modeling that includes all involved parties by
default. This is ensured by adhering to the framework RAP provides, which entails checks for all different use cases, exactly like
the controlled SAP LUW checks the contexts. The RAP-inherent checks ensure that your application is consistent and stable,
also when more than one BO is involved.
RAP divides the LUW into the interaction phase and the save sequence. Data can be changed and created in an inconsistent
state on the transactional buffer during the interaction phase. The save sequence ensures that the new state of data is
consistent and ready to be written to the database. The nal database commit is then also executed during the save sequence.
An LUW is terminated when the database commit is executed successfully and the transactional buffer is cleared, or, if the
database commit is unsuccessful. In the latter case, all work processes of the current LUW must be completely rolled back. That
means, the LUW must not leave any remains, neither on any database, nor on the transactional buffer. This is also true for BO-
external procedures. The RAP framework offers options to trigger this clean-up work. See The Save Sequence.
The RAP transactional model is seamlessly embedded in a SAP LUW. The statements to terminate a SAP LUW COMMIT WORK
and ROLLBACK WORK trigger COMMIT ENTITIES and ROLLBACK ENTITIES and thus terminate the LUW with RAP
procedures.
Note
The following violations against the SAP LUW principles will always lead to a runtime error in a RAP context:
Explicit use of COMMIT WORK or ROLLBACK WORK. The transaction handling and database commit is exclusively
handled by RAP.
Calling the update in background tasks (bgPF) in the interaction phase or the early save phase.
Some other operations only lead to runtime errors, if the RAP behavior de nition is implemented in ABAP for Cloud
Development and the strict(2)-mode is applied:
(Implicit or explicit) database commits for the primary database connection in the late-save phase.
Every BO entity instance that is involved in one LUW must be locked to avoid con icting access. Locking is tightly coupled to the
lifetime of the LUW. A lock for a BO entity instance lasts as long as the LUW. With every database commit or with a rollback, the
lock is released and the same BO instance can be used in a new LUW. For more information about the locking concept in RAP,
see Pessimistic Concurrency Control (Locking).
This is custom documentation. For more information, please visit the SAP Help Portal 200