Skip to Content

abort bsp-application

Hello !

i have one question:

......

insert xy from w_xy.

insert ab from w_ab.

if sy-subrc <> 0.

message a001(xy).

endif.

if i have this code in a normal abap-Program it works fine and if i get the abort-message from the second insert, also the first is not done.

but if i have it in a on-input-processing in my bsp-application, i do get the errormessage (thats fine for me), but the first insert is done.

does anybody no why?

how can i abort my bsp-application immediately (like with the message a... in normal abap).

thanks very much for your help

Helmut

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    May 30, 2006 at 02:25 PM

    you can use the command

    ROLLBACK WORK.

    to rollback your changes in case of subrc <> 0.

    Add comment
    10|10000 characters needed characters exceeded

  • May 30, 2006 at 11:39 AM

    can we look at it from a differnt angle. In the first place why an abort happens with a insert statement.

    if you try to INSERT a record where there is already an entry in the DB table with the same key you will get abort.

    to avoide this either use "accepting duplicate keys addition" in this case where duplicate key happens system will ignore the record and will not create a dump.

    or use

    modify <dbtab> from <work area> .

    or

    modify <dbtab> from table <itab> .

    Regards

    Raja

    Add comment
    10|10000 characters needed characters exceeded

  • May 30, 2006 at 11:52 AM

    Hello !

    thanks for your answer

    i know about the modify

    but thats not my real problem.

    there must be an insert.

    and this insert must be without any error - in any other case there is something totaly wrong with my table or coding. i just wanted to check that the insert is ok.

    i dont't like leaving the insert without a if sy-subrc <> 0 - Statement.

    but how can i abort the bsp-application if sy-subrc <> 0 immediately.

    Thanks Helmut

    Add comment
    10|10000 characters needed characters exceeded

    • Ok, the difference in the behavious between BSP runtime and ABAP runtime is because in BSP runtime the application dosent have access to some of the standard feature sof ABAP runtime.

      in your case to catch the dump and roll back the insert you have to use your insert within try catch block to capture the dump and if there is a dump you should manually do a rollback.

      I am not sure whether there is any other mechanism available for this.

      how to use try catch.

      DATA: wa TYPE sflight .
      DATA: insert_error TYPE REF TO cx_os_db_insert .
      DATA: error_message TYPE string .
      
      TRY .
          INSERT sflight FROM wa .
        CATCH cx_os_db_insert INTO insert_error.
          error_message = insert_error->get_text( ).
      ENDTRY.
      

      Regards

      Raja