Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Obsolete Language Elements →  Obsolete User Dialogs →  Obsolete Statements in List Processing →  Obsolete calculations 

SUMMING

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


SUMMING dobj. 

Effect

For every WRITE statement that after executing the SUMMING statement (which is forbidden in classes) writes the content of data object dobj to a list at any list level, implicitly the total of all values of dobj output with WRITE since the execution of SUMMING is determined and assigned to a data object sum_dobj.

The SUMMING statement declares the global data object sum_dobj with the same type as dobj. For dobj, you can specify numeric data objects. You are allowed to execute the SUMMING statement only once in a program. It may be located within a procedure, but the declared data object sum_dobj is not local.

If the content of dobj in a WRITE statement after execution of the SUMMING statement cannot be interpreted as a number or the addition results in an overflow, then an untreatable exception occurs.


Note

This statement is not permitted in classes because it works with global variables created implicitly. In its place, you can carry out explicit calculations, for example.


Example

Implicit determination of minimum, maximum, and total of a list of flight distances.

PARAMETERS p_carrid TYPE spfli-carrid.

DATA spfli_wa TYPE spfli.

MINIMUM spfli_wa-distance.
MAXIMUM spfli_wa-distance.
SUMMING spfli_wa-distance.

SELECT carrid connid distance
       FROM spfli
       INTO CORRESPONDING FIELDS OF spfli_wa
       WHERE carrid = p_carrid.
  WRITE: / spfli_wa-carrid, spfli_wa-connid,
           spfli_wa-distance.
ENDSELECT.

ULINE.
WRITE: min_spfli_wa-distance,
       max_spfli_wa-distance,
       sum_spfli_wa-distance.

In Unicode programs, the program above raises a syntax check warning, since the names of the data objects declared using MINIMUM, MAXIMUM, and SUMMING contain the invalid character "-".

Without using the implicit statements MINIMUM, MAXIMUM, and SUMMING, you can get the same result using explicitly calculated help fields.

PARAMETERS p_carrid TYPE spfli-carrid. 

DATA: spfli_wa TYPE spfli, 
      min_distance TYPE spfli-distance VALUE +99999, 
      max_distance TYPE spfli-distance VALUE -99999, 
      sum_distance TYPE spfli-distance. 

SELECT carrid connid distance 
       FROM spfli 
       INTO CORRESPONDING FIELDS OF spfli_wa 
       WHERE carrid = p_carrid. 
  WRITE: / spfli_wa-carrid, spfli_wa-connid, 
           spfli_wa-distance. 
  IF spfli_wa-distance < min_distance. 
    min_distance = spfli_wa-distance. 
  ENDIF. 
  IF spfli_wa-distance > max_distance. 
    max_distance = spfli_wa-distance. 
  ENDIF. 
  sum_distance = sum_distance + spfli_wa-distance. 
ENDSELECT. 

ULINE. 
WRITE: min_distance, 
       max_distance, 
       sum_distance.