Get Example source ABAP code based on a different SAP table
ID SUMMING • SUMMING ABAP Statement
SUMMING> Short Reference >
ABAP_SYNTAX_OBS SUMMING dobj.>
What does it do? For every 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 WRITE> since the execution of SUMMING> is determined implicitly and assigned to a data object sum_dobj>. The statement SUMMING> declares the global data object sum_dobj> with the same type as dobj>. Numeric data objects> can be specified for dobj>. The statement SUMMING> can be executed only once in a program. It can be specified 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, an uncatchable exception is raised.
Latest notes: This statement is not allowed in classes because it works with implicitly created global variables. Instead, explicit calculations> can be made. ABAP_HINT_END
Example ABAP Coding
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 WHERE carrid = @p_carrid INTO CORRESPONDING FIELDS OF @spfli_wa. 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.> The program produces a syntax check warning because 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>, the same result can be achieved using explicitly calculated help fields. ABEXA 00698 ABAP_EXAMPLE_END