SWITCH – Conditional Operator

lightSWITCH – Conditional Operator

 

 


The conditional operator SWITCH has a result from the logical expression else a class baed exception is raised.

15


CLASS cx_exception DEFINITION INHERITING FROM cx_no_check.
ENDCLASS.
DATAlv_val VALUE ‘C’.
TRY.
    DATA(lv_numSWITCH #lv_val
                             WHEN ‘A’ THEN 1
                             WHEN ‘B’ THEN 2
                             WHEN ‘C’ THEN 3
                             WHEN ‘D’ THEN 4
                             ELSE THROW  cx_exception).
  CATCH cx_exception.
ENDTRY.
WRITE:/ lv_num.


OUTPUT

16


 

Advertisements

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 )

Google+ photo

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

Connecting to %s