SmartForms
ABAP Developmentintermediate

Smart Forms Part 5: Pages, Windows and Main Window Flow

Key takeaway

Control the physical layout of Smart Forms: pages and next-page sequence, main window vs secondary windows, final windows, page breaks, page-dependent content (first page vs next pages), page numbering with SFSY fields, and common layout problems.

Explanation

📌 KEY POINTS
✅ Only the main window flows: when it is full, output continues on the next page defined in the page's "Next page" attribute.

✅ Secondary windows (header, address, footer) print fixed content per page; a final window is processed at the end, so it can show totals and page counts.

✅ System fields: SFSY-PAGE (current page), SFSY-FORMPAGES (total pages), SFSY-JOBPAGES.

⚠️ A main window with different widths on different pages causes errors; keep its width identical on all pages.

━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE

Part 4 defined data. Now we control where it appears.

━━━━━━━━━━━━━━━━━━━━
▶ 1. PAGES

  • FIRST page with full header and address; NEXT page with a compact header.
  • Page attribute "Next page": FIRST → NEXT, NEXT → NEXT.
  • Page format (DINA4, LETTER) and orientation.

━━━━━━━━━━━━━━━━━━━━
▶ 2. MAIN WINDOW

  • Exactly one main window per form; placed on each page where the flow continues.
  • Contains the item table/loop — the dynamic part.
  • Same width on all pages (height may differ).

━━━━━━━━━━━━━━━━━━━━
▶ 3. SECONDARY WINDOWS

  • Header, address, logo, footer, page number windows.
  • Content printed once per page on which the window appears.
  • Conditions on window output (e.g. only on first page: SFSY-PAGE = 1, or in "Output options" → conditions).

━━━━━━━━━━━━━━━━━━━━
▶ 4. FINAL WINDOW

Window type "Final window": processed after all others — e.g. to show "Total pages" or totals computed during the main window loop.

━━━━━━━━━━━━━━━━━━━━
▶ 5. PAGE BREAKS

  • Automatic when the main window is full.
  • Manual: command node "Go to new page" (e.g. new page per sales order in a combined form).
  • Protection: "Protect against page break" for blocks (e.g. keep an item and its texts together).

━━━━━━━━━━━━━━━━━━━━
▶ 6. PAGE NUMBERING

Text in a secondary window: "Page &SFSY-PAGE& of &SFSY-FORMPAGES&" (format e.g. &SFSY-PAGE(C)&).

━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP

  1. Create FIRST and NEXT pages with a main window of the same width.
  2. Add a page number window on both pages.
  3. Print 60 items and check the page break and numbering.

✅ CHECKPOINT: you can design multi-page forms with correct flow, headers and page numbering.

Code example

ABAP Code
* ===== Layout plan (SMARTFORMS) =====* Page FIRST (next page: NEXT)*   Window LOGO      (secondary)  graphic node, only on FIRST*   Window ADDRESS   (secondary)  address node, customer address*   Window HEADER    (secondary)  invoice number, date*   Window MAIN      (main)       item table   width 18 cm*   Window FOOTER    (secondary)  bank details*   Window PAGENO    (secondary)  "Page &SFSY-PAGE& of &SFSY-FORMPAGES&"* Page NEXT (next page: NEXT)*   Window HEADER2   (secondary)  compact header*   Window MAIN      (main)       same width 18 cm, taller*   Window PAGENO    (secondary)* Window TOTALS      (final window) totals after all items processed * ===== Condition examples (Conditions tab of a node) =====* Only on first page     : SFSY-PAGE = 1* Only if reprint         : IV_REPRINT = 'X'* Only after last item    : event "Only after end of main window" * ===== Command node for manual page break =====* Node type: Command -> "Go to new page" -> NEXT* Condition: GS_ITEM-VBELN <> GV_LAST_VBELN   (new document in combined output) * ===== Program lines node to track the last document =====* Input : GS_ITEM   Output: GV_LAST_VBELNGV_LAST_VBELN = GS_ITEM-VBELN.

Real project scenario

A delivery note printed the customer address on every page, and on long deliveries the page count showed "Page 2 of 1". The address window lacked the "first page only" condition, and the page count was in a normal secondary window processed before the total was known.
Adding the condition SFSY-PAGE = 1 and moving the page count to a final window fixed both issues.

Common mistakes

  • Different main window widths on pages.
  • Total page count outside a final window.
  • Missing Next page definition (only one page printed).
  • Secondary windows used for dynamic item lists.
  • No page protection for item blocks.

Best practices

  • One main window, same width everywhere.
  • FIRST/NEXT page design.
  • Final window for totals and page counts.
  • Conditions for page-specific windows.
  • Test with long and short documents.

Interview angle

Questions: "Difference between main and secondary windows?", "What is a final window?", "How do you print Page X of Y?"
Strong answer: main window flows across pages (one per form, same width), secondary windows fixed per page, final window processed at the end; next-page sequence FIRST→NEXT; page breaks automatic or via command node; &SFSY-PAGE& of &SFSY-FORMPAGES&; conditions for page-specific content.

Practice this lesson

Quick check

1. A 3-page purchase order prints items only on page 1. Most likely cause?

2. Main window in SmartForm is used for:

3. Which window type is normally used for long dynamic item tables that may continue to the next page?

Interview questions

1. A SmartForm item table does not continue to the second page. What is the likely issue?

Answer it in your own words first, then compare.

2. A delivery note placed a variable-length item list in a secondary window, so long deliveries were cut off. Why, and how do you fix it?

Answer it in your own words first, then compare.

Practice more with Interview AI →

Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.

More lessons in this topic

Interview questions on this topic

Related SAP topics