cancel
Showing results for 
Search instead for 
Did you mean: 

abort bsp-application

helmut_sieberer
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

StefanRoesch
Active Participant
0 Kudos

you can use the command

ROLLBACK WORK.

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

Answers (2)

Answers (2)

helmut_sieberer
Participant
0 Kudos

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

former_member184494
Active Contributor
0 Kudos

Helmut,

Have you tried any navigation to another page on the sy-subrc triggering ...

something like

navigate--> exit url...

not sure if the insert happens or not thougyh

Arun

athavanraja
Active Contributor
0 Kudos

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

athavanraja
Active Contributor
0 Kudos

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