COND – Conditional Operator

lightNew 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.

11


CLASS cx_exception DEFINITION INHERITING FROM cx_no_check.
ENDCLASS.
DATAlv_val VALUE ‘B’.
TRY.
    DATA(lv_numCOND #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).
  CATCH cx_exception.
ENDTRY.
WRITE:/ lv_num.


OUTPUT

12


No match found from the logical expression, so class based exception raised.

13


OUTPUT

14


 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s