Show TOC

Totaling and CountingLocate this document in the navigation structure



Whenever you create a list in the Query Painter, all numeric fields are automatically totaled. These totals are displayed at the end of the list. All numeric fields are also placed in the Totaling Fields toolbar. To undo totaling for specific fields, select the fields from the toolbar and drag them to the trash or drag the trash to them or to the corresponding total in your list layout.

If sort fields have been defined for your list, subtotals are automatically displayed at the end of each control level. If you want to undo subtotaling for a specific sort level, select the trash can and drag it to the appropriate subtotal on the list layout display. To suppress all subtotaling functions, deselect the field Display totals in the Output Options for Control Levels.

If you are totaling a particular field, the total is output in the same column as the field, that is with the same output length. For this reason, the output length may be too short for the total and cause overflow. ABAP identifies these overflows by placing an asterisk in front of the affected value when it is output.

To avoid overflows like this when outputting totals, you can simply increase the output length of the field.

If you total fields containing values in different currencies, the totals are created according to currency.

Currency-specific summation also applies when you specify the output of the currency amount field without a unit. Then, several currencies (without a currency) appear in the totals lines. For this reason, you should always output currency amounts with a currency.

The same applies to quantity fields. If you specify summation for a quantity field, this is performed according to the units involved and results in a distribution in the totals lines.

Counting Fields

In contrast to totals, counting fields are not automatically displayed. To count a field, proceed as follows:

  1. Choose Start of the navigation path Tools Next navigation step Counting Fields On/Off End of the navigation path

    The Counting Fields toolbar is not switched on in the standard.

  2. Drag the field you want to count to the Counting Fields toolbar.

The number of times this field appears is displayed at the end of the list. If sort fields have been defined for your list, preliminary counts are automatically displayed at the end of each control level. To suppress these preliminary counts, deselect the field Display count in the Output Options for Control Levels.

Finally, the options Total and Counter should be compared one more time.

The Total option causes the grand total of a specified numeric field to be calculated. This means that each time the field is read in a dataset, the field's value is added to the sum total. The grand total is displayed at the end of the basic list. With control levels, you can also display subtotals. A subtotal contains all values of a field that are assigned to a particular control level, that is a particular sort string.

The Counter option causes the counter number for a particular field to be increased by 1 every time that this field is found within the data set currently being read. The resulting counter total is displayed in much the same manner as a grand total at the end of the basic list. Just as with totals, counter subtotals can be displayed for individual control levels. These counter subtotals show how many values have been assigned to a particular control level.


You want to create a list that displays information about the airline ticket sales of a specific airline over a certain period of time. In addition, you want to display how many flights per flight connection are planned.

Proceed as follows:

  1. First, create a QuickView with logical database F1S as its data source. For more information, see Creating QuickViews.

  2. Select the following fields in the upper left-hand window in the Query Painter. Airline ID, Flight code, Departure airport, Departure city, Arrival airport, Destination (city), Flight date, Airplane type, Maximum occupancy, Occupied seats, and Current total of revenues.

  3. Use the trash can to delete all sum totals except for the sum total for the field Current total of revenues.

  4. Drag the fields Airline ID and Flight code to the Sort Fields toolbar.

  5. Hide the control level text for Flight code by clicking on it and undoing its field selection in the Output Options for Control Levels.

  6. Drag the Airline ID field to the trash, since it is displayed in the control level text.

  7. Click on the control level text for Airline ID and change it to Airline.

  8. Switch on the Counting fields toolbar and drag the field Flight date to it.

  9. Choose Node Assignment.The fields in the first line of the list have been taken from different levels of your logical database hierarchy.

    This means that the list is displayed as follows:

    The fields Departure city, Destination (city), and so on, have to be displayed for each connection, even though appropriate positioning of the fields could make this unnecessary. Organize your fields in such a manner that only fields highlighted in red are found in the first line. For more information, see Positioning and Sizing and in The Hierarchy Display.

  10. Change the texts for subtotals and preliminary counter totals by clicking on them.

  11. Insert separators (using the icon in the toolbox) and add additional slashes before and after list lines as you deem necessary. For more information, see List Line Output Options.

  12. Execute your QuickView. Enter an airline and a time period on the selection screen.

    A list similar to the following might appear: