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

how to do rollback with sample code.

Former Member
0 Likes
631

Hi all,

I have a requirement : we are updating the record by FM hr_maintain_masterdata in three table and if the record is get updated in two table but not in one table, it should do rollback . it should not allow to update the record in other tables also.

Kindly provide the sample code for the same.

Thanks in advance

Shweta

Edited by: shweta singh on Dec 20, 2008 1:39 PM

2 REPLIES 2
Read only

Former Member
0 Likes
512

Hi,

Just type ROLLBACK WORK in the error handling code blocks. This works only, if the function module doesn't set an explicit COMMIT WORK in itself.

COMMIT WORK.

*Changes on your first table
CALL FUNCTION hr_maintain_masterdata
.......
.......
IF sy-subrc <> 0.
 ROLLBACK WORK.
* EXIT or MESSAGE Statement 
ENDIF.

*Changes on your second table
CALL FUNCTION hr_maintain_masterdata
.......
.......
IF sy-subrc <> 0.
 ROLLBACK WORK.
* EXIT or MESSAGE Statement 
ENDIF.

*Changes on your third table
CALL FUNCTION hr_maintain_masterdata
.......
.......
IF sy-subrc <> 0.
 ROLLBACK WORK.
* EXIT or MESSAGE Statement 
ENDIF.

Regards

Mark-André

Edited by: Mark-André Kluck on Dec 20, 2008 2:53 PM

Read only

Former Member
0 Likes
512

You must not writing "COMMIT WORK" statement in function.

*Changes on your first table

CALL FUNCTION maintain_masterdata

IF sy-subrc <> 0.

ROLLBACK WORK.

  • MESSAGE Statement and Exit

EXIT.

ENDIF.

*Changes on your second table

CALL FUNCTION maintain_secondTable.

IF sy-subrc <> 0.

ROLLBACK WORK.

  • MESSAGE Statement and Exit

EXIT.

ENDIF.

*Changes on your third table

CALL FUNCTION maintain_thirdTable.

IF sy-subrc <> 0.

ROLLBACK WORK.

  • MESSAGE Statement and Exit

EXIT.

ENDIF.

COMMIT WORK.

Edited by: Jack Wu on Dec 22, 2008 11:25 AM

Edited by: Jack Wu on Dec 22, 2008 11:26 AM