Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Internal Tables →  Processing Statements for Internal Tables →  AT - itab 


Short Reference

Other versions: 7.31 | 7.40 | 7.54




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.


Control level processing for creating a list. At the end of line groups, the total of reserved places is calculated and issued.

DATA: sflight_tab TYPE SORTED TABLE OF sflight 
                  WITH UNIQUE KEY carrid connid fldate, 
      sflight_wa  LIKE LINE OF sflight_tab. 

       FROM sflight 
       INTO TABLE sflight_tab. 

LOOP AT sflight_tab INTO sflight_wa. 
  AT NEW connid. 
    WRITE: / sflight_wa-carrid, 
  WRITE: / sflight_wa-fldate, 
  AT END OF connid. 
    WRITE: / 'Sum', 
              sflight_wa-seatsocc UNDER sflight_wa-seatsocc. 
  AT END OF carrid. 
    WRITE: / 'Carrier Sum', 
             sflight_wa-seatsocc UNDER sflight_wa-seatsocc. 
    WRITE: / 'Overall Sum', 
              sflight_wa-seatsocc UNDER sflight_wa-seatsocc. 


Catchable Exceptions


  • Cause: Overflow when calculating totals
    Runtime Error: ADDF_INT_OVERFLOW
  • Cause: Value too large when calculating totals in internal table, field too small
    Runtime Error: SUM_OVERFLOW

Non-Catchable Exceptions

  • Cause: The statement SUM was used outside a LOOP processing of an internal table.
    Runtime Error: SUM_NO_INTERNAL_TABLE
  • Cause: The statement SUM was used within a LOOP processing belonging to another ABAP program.
  • Cause: The statement SUM was used within a loop starting with LOOP ... ASSIGNING.
    Runtime Error: SUM_NO_ASSIGNING