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.
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.
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.
Related Tools
Infor LN User Exit (UE) DLL Template Generator
Generate a User Exit DLL for an LN table that adds your own logic around the standard save and delete handling, without changing standard code.
Developer ToolsInfor LN 4GL Embedded SQL Select Generator
Fill in a table, columns and a where clause and get a Baan / Infor LN embedded SQL select loop with host variables, index ordering and selectempty and selecterror handling.
Infor LN & BaanInfor LN DAL Hook Review Checklist
Review checklist for LN data access layer (DAL) scripts: hook choice, validation, error handling, performance and upgrade safety.
Infor LN & BaanInfor LN 4GL Session Script Template
Generate a clean Baan / Infor LN 4GL session script skeleton with declaration, field, choice and table I/O sections.
More Developer Tools tools
See all- Infor LN DAL and User Exit Hook Functions Reference
- Infor LN Report Script Template Generator
- Infor LN ION API OAuth 2.0 REST Call Generator (Python)
- Infor LN Inbound Process.SalesOrder BOD XML Template
- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
Keep exploring
Free tools
- Infor LN DAL Hook Review ChecklistReview checklist for LN data access layer (DAL) scripts: hook choice, validation, error handling, performance and upgrade safety.
- Infor LN DAL and User Exit Hook Functions ReferenceLookup table of LN DAL object hooks, property hooks, user exit hooks and DAL functions with when they fire, what they return and the common traps.
- Infor LN Report Script Template GeneratorGenerate a 4GL report script for an LN report with program sections, layout sections, a suppress condition and a running total.
ERP fixes and how-tos
- Logic Deactivation Session in Infor LNWhat logic deactivation means in Infor LN, how it relates to DAL business logic, when it is acceptable for data loads or fixes, and the risks to control.
- Infor LN DAL Out of Sync After a Custom Field: Cause and FixInfor LN throws a DAL out of sync error after a custom field is added. Here is why table admin and DAL regeneration must run together, and the fix.
- Infor LN Studio: compile errors when building DAL/4GL codeInfor LN Studio compile errors on DAL and 4GL objects: how to read the build log, common unresolved-reference causes, and when a full rebuild fixes it.