Skip to Content
author's profile photo Former Member
Former Member

how to do rollback with sample code.

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 20, 2008 at 01: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 03: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.