ERPClimb logoERPClimb
SmartForms
ABAP Developmentintermediate 6 min read

Smart Forms Part 6: Tables, Templates, Loops and Conditions

Preview · a free account unlocks the full lesson

Key takeaway

Choose the right node for structured output: table nodes for dynamic item lists with header/main area/footer, templates for fixed grids, loops, line types and cell layout, sorting and events (subtotals), calculations, and conditions on nodes.

In this lessonShow sections

Visual overview

Smart Forms Part 6: Tables, Templates, Loops and Conditions — learning sheetFlow: Create a table node over IT_ITEMS with header, item line and footer → Add sorting by material group with subtotal event → Add a total via the Calculations tab and print it in the footer. Key ideas: TABLE NODE; SORTING AND EVENTS; CALCULATIONS TAB; TEMPLATE. Watch out: Line types must add up exactly to the table width, otherwise you get errors or shifted columns.ERPClimb.com / ABAP / LESSON 6/8 / LEARNING SHEETSmart Forms Part 6: Tables, Templates, Loops andConditions1 · HOW IT FLOWS1Create a table node overIT_ITEMS with header,item line and footer2Add sorting by materialgroup with subtotal event3Add a total via theCalculations tab andprint it in the footer2 · KEY IDEAS EXPLAINEDTable NodeData tab: loop over IT_ITEMS INTO GS_ITEM(optional WHERE condition).Table tab: line types (e.g. LINE_HEADER,LINE_ITEM, LINE_TOTAL) with column widths;borders.Sorting And EventsData tab → sort criteria (e.g. MATKL) with"event on sort begin/end".Event nodes print group headers or subtotals.Calculations TabOperation total/count/max over a field: e.g. totalGS_ITEM-NETWR into GV_TOTAL, time "afterloop".Avoid manual summing in program lines when the tabsuffices.TemplateFixed layout of cells; each cell addressed byrow/column; no looping.Use for boxes like invoice summary oraddress-and-reference blocks.3 · REMEMBER · WATCH OUTRememberTable node: dynamic number of rows (items) with header, main area andfooter; header can repeat on each page.Template: fixed grid with a fixed number of rows/columns (e.g. addressblock, summary box).Table nodes support sorting with events (subtotals on sort change) andthe "Calculations" tab for totals.!Watch outLine types must add up exactly tothe table width, otherwise you geterrors or shifted columns.4 · IN A REAL PROJECTAn invoice form printed column headers only on the first page; on 10-page invoices, auditors could not readpages 2–10 without flipping back. The header row wasn't set to repeat at page breaks. Enabling "at pagebreak" for the header and moving totals to the footer "at end" fixed the layout. Subtotals per…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 5 defined the windows of a Smart Form; inside the main window, it's the table node that actually prints the line items. A table node handles a dynamic number of rows, built from a header, a main area, and a footer, and its header can optionally repeat at the top of every page.

A template, by contrast, is a fixed grid with a fixed number of rows and columns — useful for things like an address block or a summary box where there's no looping involved. Table nodes also support sorting through events, which lets you print subtotals when a sort value changes, and they have a "Calculations" tab for totals.

On the table node itself, the Data tab defines the loop — for example, looping over IT_ITEMS INTO GS_ITEM, optionally restricted with a WHERE condition.

The Table tab defines line types (such as LINE_HEADER, LINE_ITEM, or LINE_TOTAL) along with their column widths and borders; note that line types must add up exactly to the table's total width, or you'll get errors or columns that visibly shift.

The header prints at the start of the table and, if configured for "at page break," on every new page as well. The main area prints one row per item, with cells containing text nodes that reference fields like &GS_ITEM-...&. The footer prints either at the very end, for totals, or at the end of each page.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.