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

qestion when UPDATE database table.

Former Member
0 Likes
661

hi gurus,

when i use UPDATE statement to update one record to database. how can i know it's seccessful and, if update error for table locking, how to roll back?

If this table is locking, how to release this locking?

thanks!

6 REPLIES 6
Read only

Former Member
0 Likes
637

After table update check sy-subrc variable.

sy-subrc Meaning

0 At least one line has been changed.

4 At least one line was not able to be changed, either because no appropriate line was found, or because the change would generate a line that leads to double entries in the primary key or a unique secondary index in the database table.

The statement UPDATE sets sy-dbcnt to the number of changed lines.

This information is avalaible in sap help (write update and press F1).

Locked table can be released in transaction sm12.

Regards

Read only

Former Member
0 Likes
637

-

Edited by: Sergi Marin on May 22, 2008 5:32 PM

Read only

Former Member
0 Likes
637

hi,

use commit work to save data if update was success (sy-subrc = 0), else rollback work( sy-subrc <> 0).

UPDATE <dbtab>.

if sy-subrc = 0.

COMMIT WORK.

else.

ROLLBACK WORK.

endif.

regards,

madhu

Read only

Former Member
0 Likes
637

Hi,

If SY-SUBRC = 0, the update is successful.

Shruthi

Read only

Former Member
0 Likes
637

hi

u can try in the following

update < dbt>

if sy-subrc = 0.

commit work.

message' update succesful' type

elsif sy-subrc ne 0.

rollback.

message' update not succesful' type 'i'.

endif.

afte the execution of the program

if it is not updates in the DB then the information message will be shown similarly u can give message for succesful updation in between the condition.

rewards if useful

thanks

sachhidananda

Read only

Former Member
0 Likes
637

UPDATE RECORD TO DBTABLE

IF SY-SUBRC <> 0

ROLL BACK .

ENDIF .

U CAN UNLOCK THE LOCKED RECORD USING TCODE : SM12 .

REWARD IF USEFUL