Skip to Content
author's profile photo Former Member
Former Member

catch..endcatch

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 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á

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.