Use FILTER when the key supports your condition

The dispatch table contains many rows, but a work queue needs only the open ones. FILTER constructs a new internal table from matching rows. It is not a general replacement for every LOOP or WHERE; the source table needs a compatible sorted or hashed key for the filter condition.

Name the key explicitly

DATA(open_dispatches) = FILTER ty_dispatches(
  dispatches
  USING KEY by_status
  WHERE status = 'OPEN' ).

Here, the non-unique sorted secondary key covers status, so several open rows can match. The result is a separate table; the source remains unchanged. If you need complex calculations or side effects while selecting, a loop may be more readable.

FILTER is a modern constructor expression. Check exact syntax and feature availability for the target ABAP release and language version; practice snippets are not compiled in the browser.

Sources

Developer practice · ABAP

Practice: build a table of open dispatches

Use a sorted secondary key by_status to create a new table containing only OPEN dispatches.

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