10-19-2006 11:04 AM
Hi Friends,
I'm testing a function and for that I'm forcing dumps, and catching exceptions. Divisions by zero is one of the examples.
For division by zero I'm able to catch it with an c_sy_no_handler exception, but I've another example which I'm not being able to catch it.
I'm sendind an message e001(zisa), which will exit automatically from the function module. Am I able to catch that message? Meaning, can I catch it and treat it, instead of the system exiting the function and showing the corresponding message?
10-19-2006 11:11 AM
10-19-2006 11:11 AM
10-19-2006 11:16 AM
Hi Venkat,
I've done that for the divide by zero exception. And I've tried for this as well, but cx_sy_no_handler doesn't catch it. I've looked for another cx_* but I was not able to find it. Do you know any? or any method?
10-19-2006 11:30 AM
10-19-2006 1:02 PM
Hi,
If you want to show an error message and also want to catch it raise an exception along with the message.
Ex MESSAGE e001(zisa) raising <EXCEPTION>. Declare this exception in the exception tab of the Function module.
You can also use ERROR-MESSAGE if you just want to catch the message with out raisning the exception.
Regards,
Sesh
10-19-2006 5:49 PM
Hi Seshatalpasai,
I tried to MESSAGE e001(zisa) raising cx_application_fault, where I defined the exception on the function module exceptions, but I'm not able to activate it. I get:
"you cannot use MESSAGE RAISING together with the new exceptions"....Do you have any idea on how to workaround this?
10-19-2006 6:20 PM
hi vaz
DATA: result TYPE p DECIMALS 3,
number TYPE i VALUE 11.
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 5.
DO.
number = number - 1.
result = 1 / number.
WRITE: / number, result.
ENDDO.
ENDCATCH.
SKIP.
IF sy-subrc = 5.
WRITE / 'Division by zero!'.
ENDIF.
hope this helps ,
regards,
Vijay
This program calculates the quotient of 1 and NUMBER ten times until the catchable runtime error BCD_ZERODIVIDE occurs. This runtime error belongs to the exception group ARITHMETIC_ERRORS, and is caught in the example using this class.
Message was edited by: Vijay