Chapter 10: Reports and Data Analysis
Objectives
By the end of this chapter you will be able to:
- Build AL reports with correctly scoped data items
- Link parent/child data items safely
- Apply practical filtering for useful report output
- Design report logic that fits the table/codeunit architecture
10.1 Report structure in AL
A report has two parts: the dataset (the dataitem hierarchy) and the layout (RDLC or Word). Get the dataset right first. The layout comes second.
report 50110 "Loan Installment Summary"
{
UsageCategory = ReportsAndAnalysis;
ApplicationArea = All;
dataset
{
dataitem(Installment; "Loan Repayment Schedule")
{
DataItemTableView = sorting("Loan No.", "Installment No.");
column(LoanNo; "Loan No.") { }
column(InstallmentNo; "Installment No.") { }
column(DueDate; "Due Date") { }
column(TotalAmount; "Total Amount") { }
column(Paid; Paid) { }
}
}
}
10.2 Working with data items and filters
Use filters so a report doesn’t come out oversized or full of irrelevant rows. You can filter by loan number, date range, or paid status, and sort the rows in the order the business reads them. When you nest data items, keep the links between them explicit.
This follows the “filter first” performance principle from Chapter 13.
10.3 Layout and output guidance
RDLC is the stronger choice for operational reports that need pixel-perfect output. Word layouts can be easier for document-style output. Either way, keep business calculations in the AL dataset logic, not in ad-hoc formulas in the layout.
10.4 Reporting accuracy and maintainability
When a table already calculates and enforces a field, reuse that field where you can. Don’t derive the same value again, in a different way, in report-only code. Before you release a report, check sample output against the source records.
Chapter summary
In this chapter you:
- Built a report dataset with clear business columns
- Applied useful filters and sorting
- Kept the report logic in line with the data and codeunit rules from earlier chapters
- Chose a layout deliberately, based on the output the business needs
Tasks
- Create a report. Build a report over
Loan Repayment Scheduleshowing due date and total amount. - Add filters. Add at least one request filter (for example,
Loan No.orPaid). - Validate totals. Confirm reported
Total Amountmatches table-calculated values. - Try it yourself. Add one grouped or summarized output (for example, total unpaid amount per loan).
Check your work: ensure your report reads the same business truth enforced by Chapters 7 and 9, not a duplicate formula.