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

retrieve automatically the abap exception name

Sandra_Rossi
Active Contributor
0 Likes
970

Hello,

I am an experienced abaper, and I'd like to know if there's a way to retrieve the exception name from a failed CALL FUNCTION without having to enter all the exception names (because I don't even understand what all of them are about, so I'd just like to forward the exception name):

For example, assume there is a function:

FUNCTION zzz.

IF x = 0. RAISE name1. ELSE. RAISE name2. ENDIF.

ENDFUNCTION.

I would want to do something like that

DATA excep_name(30) TYPE c.

CALL FUNCTION 'ZZZ' EXCEPTIONS OTHERS = 1.

IF sy-subrc NE 0.

excep_name = get exception name???

WRITE : / excep_name.

ENDIF.

That would print "name1" or "name2"

thx a lot

PS: I don't want to do (I am too lazy!):

CALL FUNCTION 'ZZZ' EXCEPTIONS NAME1 = 1 NAME2 = 2 OTHERS = 3.

IF SY-SUBRC = 1. WRITE : / 'name1'. ELSEIF SY-SUBRC = 2. Etc.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
813

That is the only way (your I-don't-want-to-do-it-way).

4 REPLIES 4
Read only

Former Member
0 Likes
813
Read only

0 Likes
813

error_message general exception can only be used for controlling MESSAGE e001(00) or MESSAGE a001(00) sent by the function or above. It can't control RAISE or MESSAGE ... RAISING.

Read only

Former Member
0 Likes
814

That is the only way (your I-don't-want-to-do-it-way).

Read only

0 Likes
813

thank you. Too bad!