‎2007 Dec 05 10:50 AM
Hi Experts,
I would like to know what is the exact functionality of below statement
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4.
ENDCATCH.
What it will do??
‎2007 Dec 05 10:53 AM
Hi,
catch block will be executed when the exception mentioned is raised.
see this example.
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.
rgds,
bharat.
‎2007 Dec 05 10:57 AM
Hi!
You can handle with this way some incorrect arithmetic operation, like division by zero...
Your program will not have a short dump, keeps the control, and you can write a nice error handling.
Note: there are catchable and non-catchable exceptions. Non-catchable ones will cause ABAP dump, even when they are between CATCH-ENDCATCH.
Regards
Tamá
‎2007 Dec 05 10:57 AM
Hi Neha,
When we are using some function modules in the program,there may be possibility of some arithemetic erros like dividing by zero or multiplying by some character variable ....and all.
Normally when this type of error occurs and if we dont handle/catch this type of exceptions means system goes to dump without givinvg any warning.
To avoid such type of dumps we catch through exceptions.
in our case sy-subrc = 4 ( particularly in this case) means arithemetic errors.
‎2007 Dec 05 11:03 AM
hi,
This catch statement will be used with TRY. any exceptions that will get raise in TRY statement those will be catch in CATCH statement and hence that will not give rise to any DUMP.
Regards,
Kunjal