Ask the database for a summary when the summary is all you need
If a dashboard needs only the number of delayed shipments, fetching each row and incrementing an ABAP counter transfers more data than necessary. An aggregate computes the summary at the source.
Count matching rows
SELECT FROM zi_dispatch_order
FIELDS COUNT( * ) AS delayed_count
WHERE status = 'DELAYED'
INTO @DATA(delayed_count).
The query returns an aggregate row with a count. The alias names the selected value; the target receives a scalar result.
Other aggregates
SUM, MIN, MAX, and AVG can summarize suitable numeric/date fields. Check null behavior, result types, currency/unit semantics, and rounding before using a total as a business amount. A raw sum of amounts with different currencies is not a meaningful total.
Choose SQL aggregation or ABAP processing
Use database aggregation for a compact summary over database rows. Fetch rows into an internal table when later program logic needs the individual records or when the source is already in memory. Keep the amount of data moved between database and application server intentional.
Practice
Complete the scalar target and assign it to result. The checker checks syntax fragments but does not calculate the count.
Sources
Version note: Aggregate expressions and result typing may differ across releases.
Developer practice · ABAP
Practice: count delayed shipments
Ask the database for COUNT(*) of delayed rows and store the scalar in delayed_count. Set result from the count.
This choice changes the output pattern checked here: WRITE belongs in a classic executable report, while out->write( ) uses the supplied output reference in an ABAP Cloud class-run method. It does not switch the language version of the other code; check release and API availability in your target system.
Complete the task and include the output statement shown for your selected environment. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.
0 required structures detected · 0 checks
Write your solution, then check its structure.
One possible solution
SELECT FROM zi_dispatch_order
FIELDS COUNT( * ) AS delayed_count
WHERE status = 'DELAYED'
INTO @DATA(delayed_count).
DATA(result) = delayed_count.
WRITE result.out->write( result ).These are context-specific output examples. In your own program, use the result variable from your solution and the output mechanism available in that program.