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


can anybody tell the exact procudure about exception handling in OOABAP.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Dec 05, 2007 at 01:54 PM

    Well, the OO exceptions handling it's described in three instructions:


    Every method that can raise a class-based exception (you can recognize those classes because their prefix is CX instead of CL) must be called in a TRY...CATCH...ENDTRY block.

    For example:

      cl_salv_table=>factory( IMPORTING r_table = theTable
                                        CHANGING t_table = mytable ).
      CATCH cx_salv_msg.
    * // Exception handling

    If the method FACTORY from class CL_SALV_TABLE raises an exception of the specified type (here, CX_SALV_MSG) the process branches to the CATCH block.

    In it you can handle the exception (such as send a message, call another method, exit, or anything you want).

    If, in this example, there wasn't any TRY...CATCH...ENDTRY block, process will be ended in a runtime error.

    There is another statement, CLEANUP, that it's used if an exception is triggered inside your TRY...ENDTRY block, but caught by another CATCH instruction (i.e, inside the method FACTORY).

    This will be called after the internal exception handling, leaving to you to perform cleanup tasks. Note that you cannot leave the CLEANUP block using exit commands (as RETURN, EXIT, LEAVE PROGRAM, etc..). The block must be totally performed and leaved with the ENDTRY statement.

    Hope this is clear and helps you.


    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.