ERPClimb logoERPClimb
SmartForms
ABAP Developmentintermediate 6 min read

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

Lessons are open to try during our launch period. Some advanced content may move to Pro later. AI practice limits apply separately.

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.

In this lessonShow sections

Visual overview

Smart Forms Part 5: Pages, Windows and Main Window Flow — learning sheetFlow: Create FIRST and NEXT pages with a main window of the same width → Add a page number window on both pages → Print 60 items and check the page break and numbering. Key ideas: PAGES; MAIN WINDOW; SECONDARY WINDOWS; FINAL WINDOW. Watch out: A main window with different widths on different pages causes errors; keep its width identical on all pages.ERPClimb.com / ABAP / LESSON 5/8 / LEARNING SHEETSmart Forms Part 5: Pages, Windows and Main Window Flow1 · HOW IT FLOWS1Create FIRST and NEXTpages with a main windowof the same width2Add a page number windowon both pages3Print 60 items and checkthe page break andnumbering2 · KEY IDEAS EXPLAINEDPagesFIRST page with full header and address; NEXT pagewith a compact header.Page attribute "Next page": FIRST →NEXT, NEXT → NEXT.Main WindowExactly one main window per form; placed on eachpage where the flow continues.Contains the item table/loop — the dynamic part.Secondary WindowsHeader, address, logo, footer, page numberwindows.Content printed once per page on which the windowappears.Final WindowWindow type "Final window": processedafter all others — e.g. to show "Totalpages" or totals computed during the main…3 · REMEMBER · WATCH OUTRememberOnly the main window flows: when it is full, output continues on thenext page defined in the page's "Next page" attribute.Secondary windows (header, address, footer) print fixed content perpage; a final window is processed at the end, so it can show totals…System fields: SFSY-PAGE (current page), SFSY-FORMPAGES (total pages),SFSY-JOBPAGES.!Watch outA main window with different widthson different pages causes errors;keep its width identical on allpages.4 · IN A REAL PROJECTA 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 pagecount was in a normal secondary window processed before the total was known. Adding the condition SFSY-PAGE =…Original ERPClimb learning sheet • Verify against your SAP release and edition

Expert visual walkthrough

ABAP DEVELOPMENT ACADEMY · Architecture hierarchyERPClimb.com

Pages, Windows and Main Window Flow

SmartForms · Chapter-specific technical teaching map

Architecture hierarchy

1Top level

Page node

2Related level

Secondary windows

3Related level

Main window

4Related level

Overflow page

Tutor's chapter 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.

In a real project

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…

Watch out for

• 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…

Conceptual study map, not an SAP configuration screenshot or a guaranteed runtime sequence. Consult the lesson for implementation prerequisites and exceptions.

The situation: a 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.

Explanation

Part 4 of this series defined the data a form works with; now it's time to control where that data actually appears on the page. Only the main window flows: once it's full, output continues onto the next page, as defined by that page's "Next page" attribute. Secondary windows — header, address, footer — print fixed content once per page, while a final window is processed only at the very end, which makes it the right place to show totals or page counts.

On pages: a FIRST page typically carries a full header and address, while a NEXT page carries a more compact header; the page attribute "Next page" controls the flow, for example FIRST leading to NEXT, and NEXT leading to NEXT again; each page also has its own format (such as DINA4 or LETTER) and orientation.

There's exactly one main window per form, and it's placed on every page where the flow needs to continue; it holds the item table or loop — the dynamic part of the form — and must keep the same width on every page it appears on, even though its height can differ from page to page. A main window with different widths on different pages causes errors, so keeping that width identical everywhere is essential.

Secondary windows cover header, address, logo, footer, and page-number content, and their content is printed once per page on which the window appears; conditions can control when a window actually prints — for example, only on the first page, checked via SFSY-PAGE = 1, or configured through the window's own "Output options" → conditions.

A window of type "Final window" is processed after every other window, which makes it the place to show something like "Total pages," or totals computed while the main window was looping over its data.

Page breaks happen automatically whenever the main window fills up; they can also be triggered manually with the command node "Go to new page" — useful, for example, to start a new page per sales order inside a combined form — and a block can be protected from being split across a page break using "Protect against page break," which is useful for keeping an item and its associated texts together.

Page numbering is handled through system fields in a secondary window's text, such as "Page &SFSY-PAGE& of &SFSY-FORMPAGES&" (with formatting options such as &SFSY-PAGE(C)&); SFSY-PAGE gives the current page, SFSY-FORMPAGES the total number of pages in the form, and SFSY-JOBPAGES the total for the whole print job.

To practice, create a FIRST and a NEXT page sharing a main window of the same width, add a page-number window on both pages, and print 60 items to check the page break and numbering. By the end, you should be able to 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.          " runs after the page break check, so the next item's compare sees the new document

Watch out

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.

Do this

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.

In the interview

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

0 of 3 questions attempted

Question 1 of 3

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

Practise this in an interview

Answer in your own words and get instant feedback, the way an interviewer would judge it.

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

2A 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?

Try a related Code Lab

This published exercise covers the same SAP topic. Apply the ideas in a hands-on scenario, then return to review your answers.

Open: Item Table Not Continuing to Next Page →

See it in code

Each example starts from a requirement, shows the design, then the code step by step with a plain-language explanation of every part.

Was this lesson helpful?

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.