Table expressions need a missing-row plan

A table expression such as dispatches[ dispatch_id = id ] is concise, but if no row matches it can raise CX_SY_ITAB_LINE_NOT_FOUND. Decide what absence means before using it.

Pick the behavior you need

IF line_exists( dispatches[ dispatch_id = id ] ).
  DATA(found) = dispatches[ dispatch_id = id ].
ENDIF.

If you want one safe expression instead, VALUE ty_dispatch( dispatches[ ... ] OPTIONAL ) gives an initial structure when the line is absent. DEFAULT lets you provide a fallback structure. These choices do not tell you whether the initial value came from an actual row or from absence; use an explicit existence test when that distinction matters.

Repeated lookups may perform the search twice. For performance-sensitive code, read once into a variable and handle the result, or use an appropriate key-access statement. Check release availability for the exact additions in the target system.

Sources

Developer practice · ABAP

Practice: provide a fallback for a missing row

Use a table expression to read dispatch D-1207 safely, returning an initial row rather than raising a missing-line exception.

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