# Infor LN Report Script Template Generator

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

## Short answer

Generate a 4GL report script for an LN report with program sections, layout sections, a suppress condition and a running total.

## Category

developer

## Erp

Infor LN

## Audience

- LN developer
- Report developer
- Technical consultant

## Tool

**Kind:** template

**Output:** code

**Language:** text

**Fields:**

#### Report code

**Key:** report

**Type:** text

**Default:** tdsls440101000

#### Main table of the report

**Key:** table

**Type:** text

**Default:** tdsls401

#### Quantity field to total

**Key:** qty_field

**Type:** text

**Default:** qoor

#### Suppress the detail line when

**Key:** suppress

**Type:** textarea

**Default:** tdsls401.qoor = 0

#### Author

**Key:** author

**Type:** text

**Default:** AJ

**Blocks:**

#### Header and declaration

**Body:** |******************************************************************************
|* Report script for {{report}}
|* Author: {{author}}
|******************************************************************************
declaration:

	table	t{{table}}

	double	total.{{qty_field}}
	long	lines.printed

#### Program sections

**Body:** before.program:
	| runs once before the first layout is printed
	total.{{qty_field}} = 0
	lines.printed = 0

after.program:
	| runs once after the last layout
	| for example write a log line with lines.printed

#### Layout sections

**Body:** header.1:
before.layout:
	| runs before the page header layout is printed

detail.1:
before.layout:
	| suppress this line when the condition holds
	if {{suppress}} then
		lattr.print = false
	endif

after.layout:
	| runs only after the line was printed
	total.{{qty_field}} = total.{{qty_field}} + {{table}}.{{qty_field}}
	lines.printed = lines.printed + 1

**Notes:** Edit the script in Reports (ttadv3530m000); it compiles with the report. Layout names such as header.1 and detail.1 must match the layouts defined in your report. To print the running total variable on a footer layout, add it as a report field; check in the Report Script Features part of the Infor ES Programmer's Guide how your Tools version exposes script variables and which predefined lattr variables it supports.

## Content

**Intro:** This generator writes a report script for an Infor LN 10.x report: declaration, before.program and after.program, header and detail layout sections, a condition that suppresses a detail line and a running total. Report scripts are the classic way to add logic to an LN report when the program script cannot be changed.

**Sections:**

#### How to use it

**Body:** Enter the report code, the main table the report prints, the quantity field you want totalled and the condition under which a detail line should not print. Open the report in Reports (ttadv3530m000) in your own VRC, open its script, paste the blocks and compile the report: the script compiles with it. The layout section names in the script must match the layouts of the report, so check whether your report uses detail.1 or a higher number and whether it has a header layout. Remove sections you do not use.

#### Report script structure

**Body:** Infor describes report scripts as event sections written like 4GL program scripts, with their own sections and some special functions. Program sections such as declaration, before.program and after.program run once. Report sections correspond to layouts, such as header and detail, and each can run code before the layout and after it. Text field sections handle text fields. Report scripts let you run extra queries, calculate and aggregate complex print expressions, update database rows, add fields from tables the program script does not read, and change predefined variables such as whether a layout prints.

**Bullets:**

- before.layout: set values or suppress the layout
- after.layout: totals and counters that must only include printed lines
- lattr.print = false: the layout is not printed this time

#### Worked example

**Body:** With the defaults the script skips sales order lines with an ordered quantity of zero. In detail.1 before.layout it sets lattr.print to false for those lines, so after.layout does not run for them and the running total of tdsls401.qoor counts only lines that appear on paper. Because the total is accumulated after printing, it always matches the printed lines, which is the usual cause of totals that disagree with the visible detail when people accumulate in before.layout instead.

#### Report scripts or Report Designer

**Body:** Report scripts change behaviour at the source and travel with the report in your VRC, so they suit logic every user of that report needs. For layout changes, personal variants and modern output, LN 10.x offers Report Designer, with its own development guide. If all you need is a different look or an extra field already in the data, use Report Designer and avoid a script. If you need suppression rules, extra queries or calculated totals, a report script is still the direct tool.

**Cta:** If your users mostly want answers that today need a custom report, we can let them ask LN in plain English on your own servers, with the query shown.

**Faq:**

#### How do I suppress a line in an Infor LN report?

**Answer:** In the report script, in the before.layout section of that layout, set lattr.print to false when your condition holds. The layout is not printed for that record and its after.layout section does not run. Confirm the predefined variable list for your Tools version in the Programmer's Guide.

#### Where do I edit an LN report script?

**Answer:** In Reports (ttadv3530m000). Select the report in your customer VRC, open the script and edit it. The script is compiled automatically when you compile the report, so there is no separate compile step in Program Scripts / Libraries.

#### Is there an Infor LN Report Designer development guide?

**Answer:** Yes, Infor publishes a Report Designer development guide for LN 10.x on docs.infor.com. It covers designing and personalising report layouts. Report scripts are covered separately in the Report Script Features part of the Infor ES Programmer's Guide.

#### Why does my report total not match the printed lines?

**Answer:** Usually because the total is accumulated in before.layout, which runs even for lines that are then suppressed, or because the condition is evaluated in a different layout. Accumulate in after.layout of the detail layout so only printed lines count.

## Search terms

infor ln report, infor ln reports, infor ln report script, baan report script lattr.print, report designer infor ln, infor ln report designer development guide

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