Introduction to Behavior Definition

Introduction

In the previous lesson, we discussed creating CDS views. Now, the next artifact to create after CDS View is Behavior Definition. But first, we will understand what is a general understanding of behavior definition from a simple visual.

Carefully observe the dog clips.

Introduction to Behavior Definition

We can clearly see the actions performed by a dog by just observing the clipart. These actions can also be termed as the behavior of a dog which it performs as per the situation. Similarly, for our business objects, we need to decide and define how the CDS view should behave according to requirements.

Definition

A behavior definition is an ABAP repository that represents the behavior of business objects in the context of SAP ABAP RAP.

Properties

  1. The root entity can have at most one Behavior definition defined to it.
  2. The behavior definition specifies the child entities of the root.
  3. The implementation of behavior definition is performed in Behavior Implementation Class.

How to create a Behavior Definition?

To create the behavior definition, follow the below steps:

  1. Right-click on Interface view and select New Behavior Definition.

How to create a Behavior Definition

  1. Provide Description, Package details and Implementation type. The most important part while creating the behavior definition is a selection of the Implementation type. This implementation type will define the scenarios you are working on: Managed or Unmanaged Scenario.
    Here, we have selected the Managed Scenario.

Managed Scenario

  1. Select Transport Request.
  2. And now our behavior definition is created.

behavior definition CDS

Here we have defined the simple operations CREATE, UPDATE, DELETE. We would be making use of these operations in our application.

As we are working on Managed scenario here, we don’t have to write explicit EML’s (Entity Manipulation Language) to perform these operations. This will be handled by the system. But when an Unmanaged scenario comes into the picture, we need to explicitly handle the business logic in Behavior Implementation.

We will dig deep into it in later articles.

  1. Save and activate.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.