Code :
Report Try.
Parameters NUMBER type I.
data RESULT type P decimals 2.
data OREF type ref to CX_ROOT.
data TEXT type STRING.
start-of-selection.
write: / 'Testing division and Sqare root with', NUMBER.
uline.
try.
if ABS( NUMBER ) > 100.
raise exception type CX_DEMO_ABS_TOO_LARGE.
endif.
try.
RESULT = 1 / NUMBER.
write: / 'Result of division:', RESULT.
RESULT = SQRT( NUMBER ).
write: / 'Result of square root:', RESULT.
catch CX_SY_ZERODIVIDE into OREF.
TEXT = OREF->GET_TEXT( ).
cleanup.
clear RESULT.
endtry.
catch CX_SY_ARITHMETIC_ERROR into OREF.
TEXT = OREF->GET_TEXT( ).
catch CX_ROOT into OREF.
TEXT = OREF->GET_TEXT( ).
endtry.
if not TEXT is initial.
write / TEXT.
endif.
write: / 'Final result:', RESULT.
**
No comments:
Post a Comment