Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

catch..endcatch

Former Member
0 Likes
674

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??

4 REPLIES 4
Read only

Former Member
0 Likes
626

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.

Read only

Former Member
0 Likes
626

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á

Read only

Former Member
0 Likes
626

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.

Read only

Former Member
0 Likes
626

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