How to Display Page-Wise Subtotals and Grand Total in SAP Smart Forms
Share

While developing SAP Smart Forms, we sometimes need to display a subtotal for the line items printed on each page. This becomes challenging when the number of records that fit on a page is not equal to the total number of records.

For example, suppose a document contains 10 line items. If the Smart Form layout allows only 7 line items on the first page, the remaining 3 items will be printed on the next page.

The requirement is to calculate the netwr of the 7 records printed on the first page and display that amount as the page subtotal. On the next page, the remaining 3 records should have their own subtotal. In addition, a grand total can be displayed on the final page

Solution:

Step 1: Create the required global variables

Go to:

Smart Form → Global Settings → Global Definitions.
Screenshot 2026-09-23 130246.png

Create Footer Row for Page-Wise Subtotal.

Why use "At page break only"?  The table can continue onto multiple pages. When Smart Forms reaches the end of the available space and moves the remaining records to the next page, the Footer row is triggered at the page break.

Why use At page break only

The table can continue onto multiple pages. When Smart Forms reaches the end of the available space and moves the remaining records to the next page, the Footer row is triggered at the page break.

manijangiti_0-1790149136209.png

Clear the sub total variable after each page print.

manijangiti_1-1790149236633.png

For last page and final sub total and grand total .

Just for your reference :

manijangiti_2-1790149311190.png

example Output:

 this is first page and there are total 20 pages  for each page the sub total as printed .

manijangiti_3-1790149434068.png

Now lest see final page.

manijangiti_4-1790149497559.png

this is final page output which is grand total and sub total.

Key Points

The important points of this implementation are:

  1. Maintain a separate variable for the page subtotal.
  2. Maintain another variable for the grand total.
  3. Add every line item’s NETWR to both variables.
  4. Use At page break only to print the subtotal when a page ends.
  5. Clear only the page subtotal after it has been printed.
  6. Do not clear the grand total during page processing.
  7. Handle the final page separately because it does not have a subsequent page break.
  8. Display the final-page subtotal and grand total together on the last page.

    Conclusion

    Displaying page-wise subtotals in SAP Smart Forms can be challenging when a table spans multiple pages because the number of records printed on each page is determined by the available layout space.

    By maintaining separate page subtotal and grand total variables and using the appropriate Smart Forms table events, we can achieve the required output:

      

I used AI assistance to structure and refine this blog based on my practical SAP Smart Forms implementation.
The blog explains the approach for page-wise subtotals and displaying the grand total on the final page.

 

 

  Read More Technology Blog Posts by Members articles 

#abap

By ali

Leave a Reply