Handle events with datasets
- Last Updated: April 13, 2023
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
You can write application code that handles system-generated events related to datasets. For example a system-generated event is triggered when a row is created for a temp-table. You could use the event to execute a custom event handler to calculate initial values for other fields in the temp-table record or to modify data in a related temp-table.
In ABL, a system-generated event is associated with an ABL object such as a dataset or temp-table and has a pre-defined name. You can write a custom event handler (procedure) for a system-generated event. At runtime, when an operation occurs, such as the creation of a row, the AVM automatically triggers a call to your event handler procedure. The system-generated events used with datasets and their related objects can be categorized as:
- Fill events
- Change events
- Query events
Implement dataset event handling
Event handlers are internal procedures. You add event handler procedures in the calling procedure file or you add them as internal procedures in a separate external procedure file that is run persistently. Defining event handlers as internal procedures in an external procedure enables you to keep the code related to the event handlers for a dataset in a single file. You write code to associate the event handler procedure with a dataset event so that at runtime the AVM calls a specified procedure when a named event is triggered.
To implement dataset event handling, you typically:
- Create the external procedure file to hold the event handler procedures for a dataset.
- Write the event handler code for each required dataset event.
- Run the external procedure file persistently.
- In the code that fills or changes the dataset, associate the event handler procedure with a dataset or temp-table.
Example of event handlers in an external procedure file
To implement dataset handlers as internal procedures, you create an external procedure file and add the internal procedures for the event handlers to this file. For example:
|
The event handler takes the dataset as an input parameter by reference. In the event handler code, the current record is already selected in the table.
See also
ProDataSet events in ABL Reference