‎2008 Dec 20 12:38 PM
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
‎2008 Dec 20 1:53 PM
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
‎2008 Dec 22 3:22 AM
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