Preface – This post is part of the SAP ABAP RAP series.
Table of Contents
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 ).
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:
- Once Behavior Definition is created. Right-click on Behavior Definition and select New Behavior Implementation.
- Provide the package details: name, description, package details. Click Finish.
- The new Behavior Implementation is created and is added to the corresponding folder in Project Explorer.
- 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.
- Write business logic in respective classes.
- Save and activate the class.