SAP ByD – Actions and Events

SAP Business ByDesign

In this article we’ll be talking about actions and events. In previous article we saw about What is business object and structure of business object.

sap byd actions and events

We used BODL (Business Object Definition language) for defining the business object. For actions and events, we are going to use ABSL (Advanced Business Scripting Language). This is the other set of language that is in SAP Cloud Applications Studio to be able to define actions and behavior for particular business objects.

Now we can apply ABSL to objects by using two things:

  1. Actions
  2. Events

Before entering into the Action and events we will see this table.

[table id=10 /]

Depending on whether you are implementing the business logic for business objects or the business logic for business object extensions, you can create the above script files.

In later article, we will see about business object extension.

What is Actions?

  1. An action is an element of a business object node describes an operation performed on that node.
  2. The Action operates on a set of node elements or instances that have been created or changed.
  3. Action script files are provided if you have added actions to your business object definition.
  4. Actions can be defined for custom and standard business objects.
  5. Actions can be triggered from the user interface, events, or other actions

sap byd actions and events

import AP.Common.GDT;
businessobject Bonus
   element ID : ID;
   action close;
   action cancelled;
   action CreateProjectCose; //Actions

sap byd actions and events

What is event?

  1. An event is used to compute data that can be derived from other node elements.
  2. The system executes an event implemented for custom business objects in ascending order from bottom to top, that is, from subnode to root node. In case of events implemented for extended business it is the reverse: the system executes an event in descending order from top to bottom, that is, from root node to subnode.

The following events are provided by the system:

sap byd actions and events

AfterLoading (Only available for Business Objects)
  • You can implement this event to modify transient fields of the current node of a business object. The system
    executes the AfterLoading event when it reads a node instance of a business object from the data base.
  • You cannot use an AfterLoading event to do the following:
    1. Read and modify a transient field of another node
    2. Modify a persistent field
    3. Create or delete a node
    4. Call an action
AfterModify (Available for Business Objects & Business Object Extension)
  • This happens every time some object is modified, somebody clicks enter, selects something from a search help, after an action is executed it’ll call the AfterModify event.
  • This object has not been saved yet so you can perform any kind of logic or changes in AfterModify Script.
BeforeSave (Available for Business Objects & Business Object Extension)
  • BeforeSave is triggered, after a user has clicked Save for an object.
  • You can perform any kind of logic or changes. There is no restriction.
OnSave (Available for Business Objects & Business Object Extension)

[pullquote]    Please note that the system always executes the OnSave validation after having executed the
BeforeSave event.[/pullquote]

  • You can use the OnSave validation to check whether a business object can be saved.
  • A validation is used to check if particular conditions are fulfilled, such as the conditions for saving a business object node.
  • Validations can only read data and cannot change any values.
  • The result of a validation must always evaluate to a Boolean value (true or false).
  • The system executes validations in no particular order. It executes all of the validations, i.e., even if a validation already returned false, the remaining validations are executed.
 A validation that checks whether the string “0123” is contained in the sampleData field:
 if (this. sampleData.Contains("0123")) {
 else {
Action validation (Only available for Business Object Extensions)
  • You can use an action validation to check whether an action of an SAP business object can be executed.
  • As a prerequisite, the action must be released in the public solution model (PSM).
  • The system executes the validation before it calls the corresponding action. The return value determines whether the action is executed or not.
  • You can raise messages defined in the business object extension if the action cannot be executed.


In our next article, we are going to discuss about Reusable Library. If you want to learn more about SAP ByDesign, Don’t forget to subscribe here.