Enhance the Business Object Behavior With Factory Action
- How to define factory action
- How to implement factory action
- How to preview and test enhanced travel app
Prerequisites
- You need to have access to an SAP BTP, ABAP environment, or SAP S/4HANA Cloud, ABAP environment or SAP S/4HANA (release 2022 or higher) system.
For example, you can create free trial user on SAP BTP, ABAP environment. - You have downloaded and installed the latest ABAP Development Tools (ADT) on the latest Eclipse© platform.
- You have created an ABAP Cloud Project.
- Make sure, your system has the ABAP flight reference scenario. If your system hasn’t this scenario. You can download it here. The trial systems have the flight scenario included.
In the previous exercise, you’ve defined and implemented instance action.
In the present exercise, you will learn how to add factory action.
Reminder: Do not forget to replace the suffix placeholder ### with your chosen or assigned group ID in the exercise steps below.
About: Actions:
In the RAP context, an action is a non-standard operation that change the data of a BO instance. They are self-implemented operations.
Two main categories of actions can be implemented in RAP:
Non-factory actions: Defines a RAP action which offers non-standard behavior. The custom logic must be implemented in the RAP handler method
FOR MODIFY
. An action per default relates to a RAP BO entity instance and changes the state of the instance. An action is related to an instance by default. If the optional keywordstatic
is used, the action is defined as static action. Static actions are not bound to any instance of a RAP BO entity but relate to the complete entity.Factory actions: Factory actions are used to create RAP BO entity instances. Factory actions can be instance-bound (default) or static. Instance-bound factory actions can copy specific values of an instance. Static factory actions can be used to create instances with
prefilled
default values.Further reading: Actions | CDS BDL - non-standard operations | Implicit Response Parameters | ABAP EML -
response_param