2008 May 22 4:04 PM
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!
2008 May 22 4:25 PM
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
2008 May 22 4:32 PM
2008 May 22 6:06 PM
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
2008 May 23 5:20 AM
2008 May 27 9:41 AM
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
2008 May 28 10:26 AM
UPDATE RECORD TO DBTABLE
IF SY-SUBRC <> 0
ROLL BACK .
ENDIF .
U CAN UNLOCK THE LOCKED RECORD USING TCODE : SM12 .
REWARD IF USEFUL