New COND – Conditional Operator
The new COND – conditional operator has a result which is specified in the logical expression and if no match found then a class based exception is raised.
CLASS cx_exception DEFINITION INHERITING FROM cx_no_check.
DATA: lv_val VALUE ‘B’.
DATA(lv_num) = COND #( WHEN lv_val = ‘A’ THEN 1
WHEN lv_val = ‘B’ THEN 2
WHEN lv_val = ‘C’ THEN 3
WHEN lv_val = ‘D’ THEN 4
ELSE THROW cx_exception( ) ).
No match found from the logical expression, so class based exception raised.