# Infor LN 4GL Script Template (Baan 4GL Skeleton)

> Source: https://netray.co/tools/infor-ln-4gl-script-template
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Generate a clean Baan / Infor LN 4GL session script skeleton with declaration, field, choice and table I/O sections.

## Category

infor-ln

## Erp

Infor LN

## Audience

- LN developer
- Baan developer
- Technical consultant

## Tool

**Kind:** template

**Output:** code

**Language:** text

**Fields:**

#### Session code

**Key:** session

**Type:** text

**Default:** tccuz1500m000

#### Main table

**Key:** table

**Type:** text

**Default:** tcibd001

#### Field to validate

**Key:** field

**Type:** text

**Default:** citg

#### Author

**Key:** author

**Type:** text

**Default:** AJ

#### Date

**Key:** date

**Type:** date

**Default:** 2026-10-20

#### Purpose

**Key:** purpose

**Type:** text

**Default:** Validate item group on save

**Blocks:**

#### Header and declaration

**Body:** |******************************************************************************
|* {{session}}  4GL script
|* Purpose: {{purpose}}
|* Author : {{author}}   Date: {{date}}
|* Change : initial version
|******************************************************************************

declaration:

	table	t{{table}}	| main table

	string	descr(80)
	long	retval

	extern domain tcmcs.str80	msg.text

#### Program and form events

**Body:** before.program:
	| one-time initialization, read parameters
	retval = 0

after.program:
	| cleanup, release resources

after.form.read:
	| runs after the form is built

after.update.db.commit:
	| runs after a commit of an update

#### Field and choice sections

**Body:** field.{{table}}.{{field}}:
when.field.changes:
	| react to a change
	descr = "{{field}} changed"

check.input:
	| validate the entered value
	if isspace({{table}}.{{field}}) then
		set.input.error("")
		| replace with a message code from your message table
	endif

choice.update.db:
on.choice:
	| runs before the record is updated

	after.choice:
		| runs after the standard action

#### Table I/O and functions

**Body:** main.table.io:
before.write:
	| last chance to change or reject the record

after.write:
	| follow-up logic

functions:

function extern long {{table}}.check.sample(long mode)
{
	| {{purpose}}
	return(0)
}

**Notes:** This is a structural skeleton. Section names, available events and function signatures vary by Baan or LN version and by whether you work in a 4GL session script or a DAL script. Prefer a DAL script for rules that must hold for every entry path, and test in a non-production company. Replace message handling with your own message codes.

## Content

**Intro:** Baan and Infor LN session scripts follow a fixed structure of named sections: declaration, program events, field events, choice events, table I/O and functions. This generator fills a clean skeleton with your session, table and field names so you do not retype the boilerplate for each new customization.

**Sections:**

#### How to use the generator

**Body:** Enter the session code, the main table and the field you want to react to. The output is split into blocks: header and declaration, program and form events, field and choice sections, and table I/O with functions. Copy the blocks into the script editor of the session in the Tools application development environment, then delete the sections you do not need. Keeping only the events you use makes the script easier to read and to upgrade later.

#### How the sections behave

**Body:** Declaration holds tables, variables and external references. before.program and after.program run once per session start and end. Field sections such as when.field.changes and check.input react to a user editing a field, and choice sections wrap standard actions like update.db with before and after code. main.table.io intercepts reads and writes of the main table. Functions hold reusable code. Which event fires first can matter, so test the order in your version.

**Bullets:**

- Use check.input for validation, when.field.changes for dependent values
- Use choice sections to extend a standard action
- Keep logic in functions, not scattered over events

#### Common mistakes and upgrade notes

**Body:** Putting business rules only in a session script means a different entry path, such as an import or a BDE, skips them. Rules that must always hold belong in the table's DAL. Hard-coded text instead of message codes breaks translation. Customizations placed in standard sessions rather than a customer VRC are overwritten at the next upgrade, and long-lived scripts without a change header are hard to reconcile. Document each change and keep the diff against the standard script.

**Cta:** If you are inventorying legacy 4GL and DAL customizations ahead of an upgrade or migration, we can discuss how an AI assistant reads and documents them on-prem.

**Faq:**

#### What is a 4GL script in Baan and Infor LN?

**Answer:** It is the script attached to a session that controls its behavior through named sections such as declaration, field events, choice events and table I/O. It is written in the Baan 3GL/4GL language in the Tools application development environment.

#### Should I use a 4GL session script or a DAL script?

**Answer:** Use a session script for behavior tied to one screen. Use a DAL script on the table for rules that must hold however data enters, including imports and integrations. Many customizations need both, with the data rule in the DAL.

#### Will customizations survive an LN upgrade?

**Answer:** Only if they live in your own customer VRC and are documented. Changes in standard components can be overwritten. Review each customization before an upgrade and retire any that standard functionality now covers.

#### Does this template work for Baan IV?

**Answer:** The section idea is shared, but exact event names, available functions and syntax details differ by version. Use it as a starting structure and check against a working script in your own environment.

## Search terms

infor ln 4gl script example, baan 4gl template, baan 4gl script sections, infor ln session script, before.program baan, infor ln customization script, baan 3gl 4gl skeleton

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
