There are two types of FILL events. One event type is triggered at the dataset level. The other event type is triggered at the level of the temp-table buffer of a dataset. During the FILL operation for a dataset or a temp-table buffer, events are automatically triggered in the AVM. You can write an event handler to execute custom code when a particular FILL event triggers.

Fill events at the dataset level include BEFORE-FILL and AFTER-FILL. They are shown in gray in the following illustration. Fill events at the temp-table buffer of a dataset level include BEFORE-FILL, AFTER-FILL, BEFORE-ROW-FILL and AFTER-ROW-FILL. These events are shown in blue, green, and red in the illustration, and are discussed in the next topic.

The dataset level FILL events, BEFORE-FILL and AFTER-FILL are summarized in the table.

Table 1. Dataset FILL events
Event When it occurs Examples
BEFORE-FILL Prior to the retrieval of the first record in a FILL operation; executes once per FILL operation on a dataset
  • Load data from a non database source.
  • Attach data-sources.
AFTER-FILL After the retrieval of the last record in a FILL operation; executes once per FILL operation on a dataset
  • Reject the FILL operation.
  • Detach data-sources.

Alternatively, you do not need to use an event to perform these operations. The operations can be performed before or after the call to FILL in your code.

Note: Fill events are not triggered if the FILL-MODE attribute of a dataset temp-table is set to NO-FILL.

BEFORE-FILL on a dataset

In this example, the BEFORE-FILL event handler prepares the top-level query for the FILL operation.

PROCEDURE preDataSetFill:
  DEFINE INPUT PARAMETER DATASET FOR dsOrderOrderLine.

  /* Load initial data from a JSON file */
  DATASET dsOrderOrderLine:READ-JSON("FILE","Orders.json","EMPTY").

END PROCEDURE.

In the internal procedure (preDataSetFill), the dataset is loaded with initial data from a JSON file called Orders.json.

AFTER-FILL on a dataset

In this example, after all the tables are filled the AFTER-FILL event handler detaches the data-sources for all temp-tables in the dataset.

PROCEDURE postDataSetFill:
  DEFINE INPUT PARAMETER DATASET FOR dsOrderOrderLine.
  VAR INT iBuff.
  DO iBuff = 1 TO DATASET dsOrderOrderLine:NUM-BUFFERS:
    DATASET dsOrderOrderLine:GET-BUFFER-HANDLE(iBuff):DETACH-DATA-SOURCE().
  END.
END PROCEDURE. /* postDataSetFill */

This procedure uses the NUM-BUFFERS attribute and the GET-BUFFER-HANDLE method to detach all the data-sources in a single procedure call.

See also

Define FILL events in Use ProDataSets

FILL events in ABL Reference