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

Exception handling

Former Member
0 Likes
518

HI all,

i call to method in FM and i want avoid dump when i have exception.

how i can do so since when i use try and catch and i run the fm with wrong data nothing happen .

and when i run the FM without try and catch i get dump when i put wrong data .

P.s. i put cx_ur_map in the function module raise tab .

TRY.

CREATE OBJECT lo_us.

CALL METHOD lo_uS->getles

EXPORTING

iv_ex = iv_ex

RECEIVING

rt_r = rt_uR.

CATCH cx_ur_map .

ENDTRY.

Thanks

Chris

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
482

Hi Chris,

you have to write some code after the CATCH statement to actually handle the exception, otherwise nothing will happen in case of that exception.

try the following

data: lx_error type ref to cx_ur_map,

l_message type string.

TRY.

CREATE OBJECT lo_us.

CALL METHOD lo_uS->getles

EXPORTING

iv_ex = iv_ex

RECEIVING

rt_r = rt_uR.

CATCH cx_ur_map into lx_error .

l_message = lx_error->get_text( ).

message l_message type 'E'.

" more code to handle the error

ENDTRY.

2 REPLIES 2
Read only

Former Member
0 Likes
482

Hi Chris,

In F1 help of the ABAP code you can find the possible exceptions of the class. If it is a global class go to events tab to find the exception.

If you are designing a new class then you have to define a exception method and the corresponding event in the events tab

let me know if you need any more help, For better understanding refer to BC401 doc

Cheers

Pavan

Read only

Former Member
0 Likes
483

Hi Chris,

you have to write some code after the CATCH statement to actually handle the exception, otherwise nothing will happen in case of that exception.

try the following

data: lx_error type ref to cx_ur_map,

l_message type string.

TRY.

CREATE OBJECT lo_us.

CALL METHOD lo_uS->getles

EXPORTING

iv_ex = iv_ex

RECEIVING

rt_r = rt_uR.

CATCH cx_ur_map into lx_error .

l_message = lx_error->get_text( ).

message l_message type 'E'.

" more code to handle the error

ENDTRY.