0% found this document useful (0 votes)
38 views2 pages

Z745oops22. Handling Exceptions (User-Defined Exception Messages)

The document defines a class called "abc" with a method called "m1" that takes integer parameters i_x and i_y and returns an integer e_z. Method m1 divides i_x by i_y and handles potential exceptions from a zero divide or invalid root by displaying a message. The code then creates an object of class abc, calls its m1 method by passing parameters p_x and p_y, and displays the result or exception message.

Uploaded by

AMR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

Z745oops22. Handling Exceptions (User-Defined Exception Messages)

The document defines a class called "abc" with a method called "m1" that takes integer parameters i_x and i_y and returns an integer e_z. Method m1 divides i_x by i_y and handles potential exceptions from a zero divide or invalid root by displaying a message. The code then creates an object of class abc, calls its m1 method by passing parameters p_x and p_y, and displays the result or exception message.

Uploaded by

AMR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

report z745oops22.

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

You might also like