Introduction to Behavior Implementation

by | Aug 1, 2021 | ABAP RAP

Home » SAP » ABAP » ABAP RAP » Introduction to Behavior Implementation

Preface – This post is part of the SAP ABAP RAP series.

Introduction

Once we provided the behavior of our business object in Behavior Definition, we also need to add logic to it. The logic part is done in the class, here we call it Behavior Implementation class.  A behavior definition can have one or many implementation classes (a 1: n relationship).

So, the next inline artifact to create is Behavior Implementation. The transactional behavior of business objects can be implemented in one or more global classes.

Let’s say you want to create a record in the database. You enter the data in UI and click create button. The moment you press the create button, UI data will be pushed to buffer and, from buffer it will be committed to database or rollback with proper validations. (For details on Business Object Runtime click here ).

Definition

The Behavior Implementation is an ABAP class that implements the business object’s behavior.

How to create Behavior Implementation?

Follow the below steps to create Behavior Implementation:

  1. Once Behavior Definition is created. Right-click on Behavior Definition and select New Behavior Implementation.
  2. Provide the package details: name, description, package details. Click Finish.

Introduction to Behavior Implementation

 

  1. The new Behavior Implementation is created and is added to the corresponding folder in Project Explorer.
  2. The two local classes will be automatically generated: lcl_handler and lcl_saver.

lcl_handler: This local class will be called in the Interaction phase. It contains the methods, actions, determinations which we have defined in our Behavior Definition of the business object.

lcl_saver: This class will be called in the Save sequence phase. It contains the methods for our save sequence. There are some set of pre-defined methods which will be called to persist our data to the database.

The local class implementation will be different for the managed and unmanaged transactional scenarios. We will learn this in our next articles.

How to create Behavior Implementation

  1. Write business logic in respective classes.
  2. Save and activate the class.

Author

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

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

Author