WRITE statement that
after executing the statement
SUMMING (which is forbidden in classes) writes
the content of data object
dobj onto a list of any list level, the total
of all values of
dobj output with
the execution of
SUMMING is determined implicitly and assigned to a data object
SUMMING declares the global data object
sum_dobj with the same type as
Numeric data objects
can be specified for
dobj. The statement
SUMMING can be executed 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 cannot
be interpreted as a number or the addition produces an overflow after the statement
SUMMING is executed, a non-handleable exception is raised.
This statement is not permitted in classes because it works with implicitly created global variables. Instead, explicit calculations can be made.
Implicit determination of minimum, maximum and total of a list of flight distances.
DATA spfli_wa TYPE spfli.
SELECT carrid, connid, distance
WHERE carrid = @p_carrid
INTO CORRESPONDING FIELDS OF @spfli_wa.
WRITE: / spfli_wa-carrid, spfli_wa-connid,
The program triggers a syntax check warning because the names of the data objects declared using
SUMMING contain the invalid "-" character.
Without using the implicit statements
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 WHERE carrid = @p_carrid INTO CORRESPONDING FIELDS OF @spfli_wa. 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 += spfli_wa-distance. ENDSELECT. ULINE. WRITE: min_distance, max_distance, sum_distance.