Developer ToolsFree generatorPDF, Excel, Word exportInfor LNAll Infor LN and Baan tools

Infor LN DAL Script Template Generator

This generator writes a DAL script skeleton for an Infor LN 10.x table: object hooks before.save.object and after.save.object, a property check hook, an is.mandatory hook and error handling through a message code. It is the place for rules that must hold however the record is written, which a UI script cannot guarantee.

Fill in

Logical table code, e.g. tdsls400 (sales orders).

A string field of the table, e.g. ofbp (sold-to business partner).

A message code you created in your own VRC.

Generated code
Download:

Header, include and declaration

|******************************************************************************
|* DAL script for table tdsls400
|* VRC     : B61C a7 cus1
|* Purpose : Block saving a sales order without a sold-to business partner
|* Author  : AJ
|******************************************************************************
#include <bic_dal>

table	ttdsls400

Object hook: before.save.object

function extern long before.save.object(long mode)
{
	| runs for every insert and update, from UI, AFS, BOD or import
	if mode = DAL_NEW then
		| checks only for a new record
	endif

	if isspace(tdsls400.ofbp) then
		dal.set.error.message("tdslsc0001")
		return(DALHOOKERROR)
	endif

	return(0)
}

Object hook: after.save.object

function extern long after.save.object(long mode)
{
	| follow-up actions after the record is written, e.g. update a related table
	| do not commit here: the caller owns the transaction
	return(0)
}

Property hooks

function extern long tdsls400.ofbp.check(long mode)
{
	| field-level validation, runs when ofbp is set
	if isspace(tdsls400.ofbp) then
		dal.set.error.message("tdslsc0001")
		return(DALHOOKERROR)
	endif
	return(0)
}

function extern boolean tdsls400.odat.is.mandatory()
{
	return(true)
}

Before shipping, open the standard DAL of a comparable table in Program Scripts / Libraries (ttadv2530m000) and the Data Access Layer chapter of the Infor ES Programmer's Guide for your Tools version, and confirm the hook signatures, the DAL_NEW constant, DALHOOKERROR and dal.set.error.message exactly as your version defines them. The string check uses isspace, so field1 must be a string field. Compile as script type DAL in your customer VRC and test both through the session and through an integration path (AFS or BOD).

Have your DAL reviewed before go-live

Send us your DAL script and LN version and we will check hook usage, transaction handling and integration paths.

Optional. The tool and every export work without this. No spam.

Was this tool useful?

How to use it

Enter the logical table code, your customer VRC, the string field you want to validate, a field to make mandatory and the message code you created for the error. Copy the blocks into a new script of type DAL for that table in Program Scripts / Libraries (ttadv2530m000), keep only the hooks you need and compile. The before.save.object hook shows the pattern every DAL check follows: test the condition, set an error message, return DALHOOKERROR; return 0 when the record is fine. The mode argument tells you whether the record is new or changed, so you can run some checks only on insert.

Where DAL logic runs

LN introduced DAL 1 scripts in Baan 5.0 to keep integrity rules with the table instead of in each session. Object hooks replace the main.table.io sections of older program scripts. Because the DAL sits under every entry path, the same check fires for a user in the session, an AFS program, an inbound BOD through the LN business adapter and an exchange import. That is the reason to put data rules here rather than in a 4GL UI script, which only protects one screen.

  • Object hooks: logic for the whole record on save or delete
  • Property hooks: logic tied to one field, such as check and is.mandatory
  • Script type in ttadv2530m000: DAL

Worked example

With the defaults, the script refuses to save a sales order header in tdsls400 when the sold-to business partner (ofbp) is empty and marks the order date (odat) as mandatory. A user in the sales order session sees your message; an inbound Process.SalesOrder BOD gets the same message back in its acknowledgement; an AFS program receives it in its error string. When importing through the DAL, LN logs hook errors, but if a hook sets several messages only the first is logged, so make that first message specific.

Gotchas

Never commit or abort a transaction inside a hook: the DAL runs inside the caller's transaction and a commit there corrupts the caller's unit of work. Keep hooks fast, because they run for every row of a mass update. Avoid user interaction in a DAL; there is no form when a BOD or import calls it. Test with both the UI and an integration path, since a rule that depends on session variables behaves differently without a session. Put customer DAL changes in your own VRC, document them, and diff them against the standard script before every upgrade.

Frequently Asked Questions

What is a DAL in Infor LN?

The Data Access Layer is a script attached to a table that holds its integrity logic. It runs whenever the table is written through LN, regardless of whether the call comes from a session, AFS, a BOD or an import, which makes it the right place for rules that must always hold.

How do I return an error from a DAL hook?

Set a message with dal.set.error.message using a message code from your VRC, then return DALHOOKERROR from the hook. Return 0 when the check passes. Confirm the exact names in the Programmer's Guide for your Tools version, and use message codes rather than hard-coded text so the message can be translated.

Where is the Infor LN development guide for DAL?

The Data Access Layer chapter of the Infor ES Programmer's Guide covers hooks and functions in detail; Infor references it as a Support Portal knowledge base document. The LN online help also has DAL 1 and DAL 2 overview pages. LN Studio and the Tools sessions are where you edit and compile the script.

DAL script or 4GL UI script: which one?

Use the DAL for data rules that must hold on every entry path. Use the UI script for screen behaviour such as defaults, enabling fields and user prompts. Logic only in the UI script is skipped by BODs and imports, so integrations will create records your UI would have rejected.

If you want an assistant that reads and documents your existing DAL customizations on-prem before an upgrade, we can set that up on your own servers.

ArchRay builder
Design the on-prem AI stack for Infor LN and Baan: model, GPUs, RAG pipeline, guardrails
See memory, speed and cost as you swap parts, then export the diagram. Free, in your browser.
Open the builder

Keep exploring

Free tools

ERP fixes and how-tos

Guides

Software