A user exit include and a user top include are defined in the application form attributes.
1. Determine the global data field the total is to be based on, for example, WA_CUSTOMER-FORCURAM.
2. Choose Goto ® User top include ®Display/Process to navigate to the user top include. Define a summation variable (for example, DATA SUM LIKE WA_CUSTOMER-FORCURAM >). Navigate back to the application form.
3. Place the cursor on the form level from which you wish to run the summation. Choose Choose.
4. Specify a name for the exit before loop (such as INIT_SUM) and the exit during loop (such as PERFORM_SUM). Choose Continue.
5. In the hierarchy display, the two symbols B and D (for “before” and “during”) now appear on the level on which the cursor is still placed. First choose B to navigate to the exit before loop.
6. Trigger the summation with the ABAP order CLEAR SUM. Navigate back to the application form.
7. Choose D to navigate to the exit during loop.
8. Enter the summation order, (such as ADD WA_DOC_ITEM-NETTOBTR TO SUM). Navigate back to the application form.
9. Issue the total in the form by placing the symbol &SUM& in a text after the form level (for example, same level).
10. Activate the application form.
Summation is only performed if you print and it is then output in the text.
If you need the total before a text is printed, if, for example, you want to make the layout of the form dependent on the total, SAP recommends that you first run the summation without text nodes in the form. You can then issue the text using a second form level with the same name.