Z745oops22. Handling Exceptions (User-Defined Exception Messages)
Z745oops22. Handling Exceptions (User-Defined Exception Messages)
Handling Exceptions
(User-defined Exception messages)
class abc definition.
public section.
methods m1 importing i_x type i i_y type i
exporting e_z type i.
endclass.
class abc implementation.
method m1.
try.
write :/ 'begin of method m1'.
e_z = i_x / i_y.
write :/ 'end of method m1'.
* catch cx_sy_zerodivide.
catch cx_root.
message 'Cannot divide by zero' type 'I'.
endtry.
endmethod.
endclass.
start-of-selection.
data ob type ref to abc.
create object ob.
parameters : p_x type i,
p_y type i.
data lv_z type i.
call method ob->m1
exporting
i_x = p_x
i_y = p_y
importing
e_z = lv_z.
write :/ 'Division is ',lv_z.
write :/ 'End of program..'.