on 03-04-2014 6:34 AM
Hi ,
I want to raise an exception from my method.....I am doing division operation inside my method...when I am entering a very large amount , that time I am getting run time error.....please someone help me to catch this exception and display on browser.
Thanks & Regards
Suman Kumar
Hi Suman,
You can catch the arithmetic exception by using exception class CX_SY_ARITHMETIC_ERROR as below
Sample code:
data lv_ex_msg type string.
data lx_sy_error type ref to CX_SY_ARITHMETIC_ERROR.
try.
"here goes your code
catch CX_SY_ARITHMETIC_ERROR into lx_sy_error.
" you can get exception text as below
lv_ex_msg = lx_sy_error->get_text( ).
or
" lv_ex_msg = lx_sy_error->get_longtext( ).
endry.
Hope this helps you.
Regards,
Rama
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suman,
No need to use exception tab of method in your case.
You are just catching the text of exception.
....
We use the exception tab of method when we need to return some exception raised in the method to other method.
Example:
let us say we have methods : method_1 with exception EX_1 & other method method_2 which calls the method_1 inside
method method_2.
call method method_1
exporting
a = lv_p
exceptions
ex_1 = lx_1.
endmethod.
Hope this helps you.
Regards,
Rama
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.