DAL

The Data Access Layer (DAL) allows developers to describe rules about data. A DAL is linked to a table, not a session. Therefore, when the table is accessed, the DAL is used. In this way, different sessions can update a table by using the same rules. In addition, integration capabilities use the DAL to ensure updates are also processed with the same rules.

Data Access Layer (DAL) scripts implement the business rules of the application to ensure the logical integrity of the database. DAL scripts are a Library software component that is aligned with a specific table. These scripts are compiled into objects. When a session performs an action on a table, the DAL for the table is loaded.

In LN, two types of Data Access Layer scripts exist: DAL 1 and DAL 2.

Business Rules

A business rule is a statement that defines or constrains some aspect or operation of the business. It is intended to control or influence the behavior of the business operations. Business rules are logical integrity rules, and differ from database oriented referential integrity rules.

Business Rules - example

Business rules in a purchasing system may be:

  • An item can be ordered only from its supplier
  • When the gross weight and net weight for an item are the same, there is no packaging
  • The supplier provides the arrival date of a purchase order after the order is entered into the system.
  • Items cannot be removed if there is stock on-hand
  • The item on-order quantity is increased when an order for the item is entered
  • The item on-hand quantity is increased and the on-order quantity decreased when an order arrives

Referential Integrity Rules - example

In contrast, integrity rules in a purchasing system may be:

  • An item must exist for it to be ordered
  • If an item has a supplier, the supplier must be known to the system
  • Items can not be deleted if the item record is used elsewhere in the system

Business rules are implemented as hooks. A hook is a pre-defined function name that you create in a Data Access Layer script. The 4GL engine will call this function as it executes user interface and database related actions on the table that the DAL is written for.

Business rules fall into categories that determine how the business rule is implemented in the DAL.

The categories, depending on the type of DAL script, are:

  • Property or Field hooks
  • Object Hooks
  • Field Dependencies
  • Business Methods
DAL 1

DAL 1 scripts were introduced in Infor Baan 5.0.0. A DAL 1 script contains database logic (e.g. logical integrity rules), but it usually does not contain all business logic for the table it belongs to. Very often business logic is spread across the DAL 1 script and the UI scripts.

Most UI scripts still contain business logic. They can contain, for example, logic to:

  • make fields read-only.
  • determine which enum constants can be selected in an enumerated field.
  • update a field after a change to a related field.

Therefore it is very hard to use the DAL 1 scripts for integrations via Infor LN Business Adapter: the business logic in the UI scripts is skipped if another application connects to a LN table. Therefore this logic must be rebuilt in the BOIs that provide the connection. If you change the business logic in the UI scripts, you must adapt the corresponding BOIs as well.

A DAL 1 script can contain the following types of hooks:

  • Object hooks. These hooks operate on the row or record as a whole unit. Object hooks determine if operations on a row are allowed, and specify additional operations that should be performed based on an operation of the row. Examples of object hooks are:
    • Delete the additional employee data in the People package when an employee is deleted.
    • When a sales order line is saved, create a history record of the sales order line.
    • Update the item inventory when a planned stock transaction is created.
  • Property hooks. These hooks operate at a field level, and are, among other things, used to verify valid values and calculate default values for table fields. Examples of property hooks are:
    • Validity check that the Quotation expiration date should be after the Quotation entry date.
    • When adding an employee, the language of the company is the default for the employee’s language.

For details on DAL 1 scripts, refer to "Data Access Layer" in the Infor ES Programmer's Guide.

To create DAL 1 scripts

You can create and edit DAL 1 scripts in the Program Scripts / Libraries (ttadv2530m000) session. For DAL 1 scripts, the script type is "DAL".

DAL 2

DAL 2 scripts are introduced in LN. A DAL 2 script contains all business logic (database logic + other logic) related to a particular table. The UI scripts of the sessions operating on the table, only contain UI logic.

DAL 2 scripts are therefore perfectly suited for integrations via Infor LN Business Adapter. Other applications can connect, through Business Objects, to LN tables. The business logic in the table's DAL 2 script is executed automatically. So, to build an integration, you don't need to rebuild this business logic in the BOIs that provide the interface.

Various predefined Business Objects, that can be used for integration purposes, are delivered with LN. DAL 2 scripts are only available for tables that are used in these business objects. For the remaining tables, DAL 1 scripts are available. Refer to the Infor LN Business Adapter documentation for details on business objects and integration technology.

In DAL 2 various new hooks are introduced. A DAL 2 script can contain:

  • Object hooks: these hooks are identical to the object hooks in DAL 1 scripts.
  • Field hooks. Field hooks contain the business logic for table fields. They can contain, for example, logic to:
    • verify valid values on a table field (logical integrity rules).
    • make a field read-only. For example: the contact field of the Business Partner is not a required entry, and is a display field in the UI when the Business Partner is created.
    • make a field invisible.
    • automatically update a field, after a related field was changed. See "Field Dependencies".
    • make input on a field mandatory.
    • hide a particular enumerated constant from an enum list.
  • Business method hooks. These hooks are used to disable/enable and hide specific form commands of type "business method".

For details on DAL 2 scripts, refer to "DAL 2 Overview" in the Infor ES Programmer's Guide.

To create DAL 2 scripts

You can create and edit DAL 2 scripts in the Program Scripts / Libraries (ttadv2530m000) session. For DAL 2 scripts, the script type is "DAL (version 2)".

Field dependencies

In DAL 2 scripts, you can define field dependencies that are used to determine default values. Once these field dependencies are defined, dependent fields update themselves when the fields that they depend on are updated. The field updates are defined in the DAL as a field hook.

Dependencies are also used to update the User Interface. The 4GL Engine uses these field dependencies to disable and enable fields, and to determine enum values.

Examples of field dependencies are:

  • The packing field of the Item is yes if the gross weight and net weight of the item are different. A field dependency is defined so that the packing field is updated if the gross or net weight fields change.
  • An item without a gross weight cannot have a net weight and packing. A field dependency is defined so that the net weight and packing fields are disabled if the gross weight is zero.
Business methods

Business Methods are operations on a row or set or rows within a table. A business method is a function that performs a task that involves manipulating or checking one or more tables in the database.

Sessions, object hooks or property hooks from another table’s DAL can call a business method. For more information, refer to the Infor ES Programmer's Guide.

Examples of business methods are:

  • The sales order line session can remove an order line. The object hook for deleting the sales order line calls a business method to also remove the unpaid commissions.
  • In the Purchase Order session, check if it is allowed to change a purchase order header based on the purchase order status and the business partner status.
  • If a purchase order issues components, the object hook for the purchase order line calls a business method to issue the components for the purchase order. The business method inserts items of the bill of material into a purchase order components table.