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

abap:exception

aneel_munawar
Participant
0 Likes
1,794

Dear Abappers,

I am facing some issue . I have written this code.


try.

    MODIFY dt_tabcst INDEX 0.

CATCH cx_root.

   EXIT.

ENDTRY.

but unable to catch the exception.  I  get screen dump  .  table_invalid_index    runtime error.  How  can i catch this error.?

Regards

Aneel

1 ACCEPTED SOLUTION
Read only

former_member302911
Active Participant
0 Likes
1,501

Hi Aneel,

TABLE_INVALID_INDEX is uncatchable runtime error.

To verify that an exception is catchable, go to ST22 and see column Exception.

If exception is filled is catchable, if not is uncatchable.

Regards,

Angelo.

7 REPLIES 7
Read only

Former Member
0 Likes
1,501


index 0 is invalid. must be at least 1

Read only

Former Member
0 Likes
1,501

you need to declare one variable to catch exception.

Please follow following snap of code to catch the exception.

data : res type i.
parameters : num1 type i,
             num2 type i.

data : obj type ref to cx_root.
data : msg type string.
try.
  res = num1 / num2.
  write 😕 'result =', res.
  catch cx_root into obj.
    msg = obj->get_longtext( ).
    write 😕 msg.
  endtry.


suppose we are dividing two number. by mistake i divided nmber by 0.

that time it will work.



Read only

Former Member
0 Likes
1,501

Index should not be zero. Please check. Hope the modify statement written inside the loop and Table dt_tabcst is defined with header line.

Just put break point on Modify statement and check system variables SY-MSGID / SY-MSGNO to get the details of error.

BR,

Prakash

Read only

0 Likes
1,501

Dear All,

i  know that error is  due to index  0.  But  it should catch the exception .  but it  does not   catch.

Read only

Former Member
0 Likes
1,501

try to handle like me how i handled.

you will get a solution.

Read only

former_member302911
Active Participant
0 Likes
1,502

Hi Aneel,

TABLE_INVALID_INDEX is uncatchable runtime error.

To verify that an exception is catchable, go to ST22 and see column Exception.

If exception is filled is catchable, if not is uncatchable.

Regards,

Angelo.

Read only

0 Likes
1,501

THANKS Angelo,

I got it.

ST22   is also useful.


Regards

Aneel