Implement a First Function in ABL
Backend logic can be included in ABL. The following instruction is based on the use case where a field is filled with text every time a DSO is read.
For this use case, a screen with an entity named 'eAddress' and at least one field named 'Name2' is used.
In your Gitpod environment got to
src\backend\
.Create a new folder.
Create a new file
<Name>EventHandler.cls
in the previously created folder.Type
b1-datasourceEventHandler
in the new file to insert an EventHandler.Save the changes.
In the Build.One Platform go to Integrate > Data > Datasource.
Click the Generate Dataset-Definition button.
Select the desired DSO in the Data Source Object field.
Copy the generated Dataset Definition.
In your Gitpot environment create the file
dsAddress.i
in the previously created folder.Paste the copied Dataset Definition into the
dsAddress.i
file.
Include the
dsAddress.i
as follows:INHERITS Akioma.Swat.OERA.Dynamic.BaseServerEventHandler: { <Name of the previously creatded folder>/dsAddress.i &ACCESS="PRIVATE" }
Rename the constructor as follows:
CONSTRUCTOR <Name>EventHander():
Enter the following code:
METHOD PROTECTED OVERRIDE VOID OnAfterFetch(): FOR EACH eAddress NO-LOCK: ASSIGN eAddress.Name2 = "HelloWorld from Backend". END. END METHOD.
Open the DSO at the root level.
In the Attributes panel, enter the value 'Training.TrainingEventHandler' for the
ServerEventHandler
attribute.