COND type( WHEN operand = const1 THEN result1
[ WHEN operand = const2 THEN result2 ]
...
[ ELSE resultn ] )
Example
Conditional operator SWITCH in an operand position in a loop. The
loop is exited when the exception after ELSE is caught.
CLASS cx_overflow DEFINITION INHERITING FROM cx_static_check.
ENDCLASS.
DATA(out) = cl_demo_output=>new( ).
DO.
TRY.
out->write(
SWITCH string( sy-index
WHEN 1 THEN 'one'
WHEN 2 THEN 'two'
WHEN 3 THEN 'three'
ELSE THROW cx_overflow( ) ) ).
CATCH cx_overflow.
out->display( ).
EXIT.
ENDTRY.
ENDDO.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved