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

exception

can anybody tell about the exception handling in abap and its importance in case of function modules.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 01:19 PM

    hi

    good

    Check this:

    ... EXCEPTIONS except1 = rc1 ...exceptn = rcn

    Effect

    EXCEPTIONS lists the exceptions to be handled by the calling program itself. At the end of the exception list, you can use OTHERS to refer to all the remaining exceptions.

    If one of the listed exceptions occurs, SY-SUBRC is set to the appropriate value rc (a numeric literal!) and control passes back to the calling program. By specifying a return code, you can divided the exceptions into classes. With the second form, without "=rc", SY-SUBRC is set to a value other than 0 if an exception occurs.

    If the function module triggers an exception (with the statements RAISE and MESSAGE ... RAISING) and the exception is not to be handled by the calling program itself,

    RAISE terminates the program with a runtime error;

    MESSAGE ... RAISING outputs the message.

    Note

    The following EXCEPTIONS are predefined by the system and have a special meaning:

    OTHERS: Covers all user-defined exceptions in the called function module.

    ERROR_MESSAGE: This exception instructs the system to ignore S messages, I messages and W messages until return from the function module (although they still appear in the log during background processing). When an E message or an A message occurs, the called function module terminates, as if the exception ERROR_MESSAGE has been triggered.

    Example

    DATA: WA_SFLIGHT TYPE SFLIGHT,

    P_LOSS LIKE SFLIGHT-PAYMENTSUM,

    P_REVENUE LIKE SFLIGHT-PRICE,

    P_CARRID LIKE SFLIGHT-CARRID.

    ...

    SELECT * FROM SFLIGHT INTO WA_SFLIGHT WHERE CARRID = P_CARRID ... .

    CALL FUNCTION 'CALCULATE_REVENUE_LOSS'

    EXPORTING

    PAYMENTSUM = WA_SFLIGHT-PAYMENTSUM

    SEATSOCC = WA_SFLIGHT-SEATSOCC

    PRICE = WA_SFLIGHT-PRICE

    IMPORTING

    LOSS = P_LOSS

    REVENUE = P_REVENUE

    EXCEPTIONS

    OTHERS = 1.

    ...

    ENDSELECT.

    ...

    Example

    TABLES SFLIGHT.

    DATA: ITAB TYPE STANDARD TABLE OF BCAXX WITH

    NON-UNIQUE DEFAULT KEY INITIAL SIZE 10.

    P_YEAR ... .

    CALL FUNCTION 'FILL_SEATTAB'

    EXPORTING

    YEAR = P_YEAR

    TABLES

    SEATTAB = ITAB

    EXCEPTIONS

    NO_ENTRY = 1

    OTHERS = 2.

    CASE SY-SUBRC.

    WHEN 1. ...

    WHEN 2. ...

    ENDCASE.

    thanks

    mrutyun^

    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.