Turn a list into a useful answer

The fictional warehouse has several bins. A bin needs attention when its quantity is below the minimum. The goal is to count how many bins need restocking.

Use an explicit loop first

DATA(result) = 0.
LOOP AT bins INTO DATA(bin).
  IF bin-quantity < minimum.
    result = result + 1.
  ENDIF.
ENDLOOP.

The loop visits each row; the condition checks one field; the counter increases only for a match. This explicit version is easy to inspect in a debugger and is a good starting point for beginners.

Alternatives

If you need the matching rows for later processing, filter into a new table with a FOR expression inside VALUE. If you only need one summary value and the expression remains readable, REDUCE can accumulate it. The loop is often clearest when learning or when the logic has several steps.

Practice

Use the prepared bins table and minimum. Count matching rows in result, then use output for the chosen environment. The checker does not run the table or calculate the actual answer.

Sources

Version note: Modern inline declarations and expression alternatives may not be available in older releases or every language version.

Developer practice · ABAP

Practice: count bins below minimum stock

Initialize result to zero. Loop over bins, and increment it when bin-quantity is below minimum.

Choose your ABAP environment

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