Skip to content

Access table key with uncertain result

DATA(account) = VALUE #( accounts[ id = '4711' ] OPTIONAL ).

By default, failing functional key accesses throw an exception. The addition VALUE ... OPTIONAL suppresses this.

Old style:

TRY.
    account = accounts[ id = '4711' ]
  CATCH cx_sy_itab_line_not_found.
ENDTRY.
From SAP/styleguides under CC BY 3.0 — more details
Last updated on