Skip to Content

Catch db table modification failure

Hi,

I searched the forum for a way to catch the reason for failure of a DB table modification but didn't find any clue for a solution.

When I use the modify statement I only get sy-subrc as 0 or 4 as an indication to the modification.


How can I understand the reason for failure when sy-subrc = 4?


Thanks,

Hagit

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 28, 2016 at 11:19 AM

    Hi Hagit Peretz ,

    As per my understanding by reading this thread come to know that you need to get the real time message during database updation. Try code as shown in below.

    DATA :lx_root TYPE REF TO cx_root,

    err_msg TYPE char200.

    LOOP AT MY_SRC.

    TRY.

    MODIFY MY_DB_TAB FROM MY_SRC.

    CATCH cx_root INTO lx_root.

    err_msg = lx_root->get_text( ).

    ENDTRY.

    ENDLOOP.

    " It's in loop so that for each record you will get the status. Populate err_msg status in final table.

    Regards,

    PrAvIn

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 28, 2016 at 08:57 AM

    Hi

    It should be very rare event, because the MODIFY statament can be both INSERT or UPDATE (it depends on the record to be updated),

    anyway frim the help:

    0All lines were inserted or changed.4At least one line could not be processed as there is already a line with the same unique name secondary index in the database table.

    so it could be a conflict due to the secondary index

    Max

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Hagit Peretz

      Hi

      So have you a dump? I've understood you need to know why the MODIFY returns a SY-SUBRC = 4

      If you want to prevent that dump, you need to use TRY/ENDRTY

      DATA: MY_ERROR TYPE REF TO CX_SY_CONVERSION_NO_NUMBER.

      DATA: MSG_ERROR TYPE STRING.

      TRY.

      <COMMAND.....................................>.

      CATCH CX_SY_CONVERSION_NO_NUMBER INTO MY_ERROR.

      MSG_ERROR = MY_ERROR->GET_TEXT( ).

      ENDTRY.

      IF MSG_ERROR IS NOT INITIAL.

      .................do something................................

      MESSAGE I208(00) WITH MSG_ERROR.

      ENDIF.

      Max

  • Posted on Jul 28, 2016 at 07:49 AM

    Are you modifying From from work area or From the table.

    Where is modify statement.

    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.