SAP SUM ABAP Statements

Get Example source ABAP code based on a different SAP table
  


Standard SAP Help for SUM

SUM

Short Reference
• SUM ABAP Statement


ABAP Syntax SUM.


What does it do? The statement SUM can only be specified within a loop starting with LOOP, and is only considered within a AT-ENDAT control structure. Prerequisites for using the statement SUM include using the addition INTO in the LOOP statement, and that the specified work area wa is compatible with the row type of the internal table. In addition, SUM cannot be used when the row type of the internal table itab contains components that are tables.

The statement SUM calculates the sums of the components with numerical data type of all rows in the current group level and assigns the sums to the components of the work area wa. In the control levels FIRST, LAST, and outside of an AT-ENDAT control structure, the system calculates the sum of numeric components of all rows in the internal table.



Example ABAP Coding
See Control Level
Processing with Totals.



Runtime Exceptions

Catchable Exceptions
CX_SY_ARITHMETIC_OVERFLOW
Reason for error:
Overflow when calculating totals
Runtime error:
ADDF_INT_OVERFLOW
Reason for error:
Value too large when calculating totals in internal table, field too small
Runtime error:
SUM_OVERFLOW


Non-catchable Exceptions
Reason for error:
The statement SUM was used outside a LOOP processing of an internal table.
Runtime error:
SUM_NO_INTERNAL_TABLE
Reason for error:
The statement SUM was used within a LOOP processing belonging to another ABAP program.
Runtime error:
SUM_ON_FOREIGN_INTERNAL_TABLE
Reason for error:
The statement SUM was used within a loop starting with LOOP ... ASSIGNING.
Runtime error:
SUM_NO_ASSIGNING

Return to menu