Mentor SAP

Action Definition

Actions in RAP

 

In RAP, an action is a non-standard modifying operation that is part of the business logic.

 

You define an action for an entity in the behavior definition using the action keyword. The logic of the action is implemented in a dedicated method of the handler class.

 

By default, actions have an instance reference and are executable by OData requests as well as by EML from any ABAP coding (public instance action).

The following special types of actions exist:

 

When defining an RAP action, defining parameters is optional. Parameters can be input or output parameters.

Action Definition
The behavior definition in the example defines two public actions: a static action and an instance action. The static action has no parameters at all. The instance action has a result parameter with cardinality [0..1] and the symbolic type $self. The type $self indicates that the result has the same type as the entity. The action can return up to one data sets of type D437_I_Text.

 

Action Implementation

The Behavior Implementation (Behavior Pools)

 

The transactional behavior of a business object in the context of the current programming model is implemented in one or more global ABAP classes. These special classes are dedicated only to implementing the business object's behavior and are called behavior pools. You can assign any number of behavior pools to a behavior definition. Within a single global class, you can define multiple local classes that handle the business object's behavior. The global class is just a container and is basically empty, while the actual behavior logic is implemented in local classes.

Definition of the Behavior Pool

 

In an unmanaged implementation scenario, a behavior pool is always required.

 

In a managed implementation scenario, a behavior pool is only required if the behavior definition contains components that can't be handled by the managed RAP BO provider, such as actions or validations.

 

You specify a behavior pool for the RAP business object by adding implementation in class unique to the behavior definition header (statement managed or unmanaged). The mandatory addition unique defines that each operation can be implemented exactly once.

 

Creating the Behavior Pool