Application Development 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: 

How to raise custom exceptions?

Former Member
0 Kudos

Folks,

In my ABAP code, I need to raise an exception:


    IF sy-subrc = 1.
       RAISE table_not_available.
    ENDIF.

Here, instead of raising a generic exception such as table_not_available, I would like to raise a more meaningful exception where the table name is also displayed as part of the exception. Something like:

RAISE 'Table ' + tableName + ' not available.'

How can I create such custom exceptions?

Thank you in advance for your help.

Regards,

Peter

3 REPLIES 3

Former Member
0 Kudos

Try doing this via Message statement under the exception.........I am not sure whether u can raise exception like this.

Former Member
0 Kudos

Try:

REPORT ztest LINE-SIZE 132 MESSAGE-ID 00 LINE-COUNT 65.

DATA: tab_name(20) VALUE 'BKPF'.

sy-subrc = 1.

IF sy-subrc = 1.
  MESSAGE e398 WITH 'Table ' tab_name 'not available' RAISING
               table_not_available.
ENDIF.

Rob

0 Kudos

Hello,

Thank you for your help. I will try this out.

Regards,

Peter