Skip to Content
avatar image
Former Member

commit work and roll back with simple language and simple example

hi guru

commit work and roll back with simple language and simple example

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 16, 2007 at 03:59 AM

    hi,

    here is one example i found somewhere, it will help you understand commit and rollback.

    REPORT ZTEST.

    TABLES : ZYDTABLE01.

    DATA: IT_TAB01 LIKE ZYDTABLE01

    OCCURS 0 WITH HEADER LINE.

    IT_TAB01-ZTEXT01 = 'DAVID'.

    IT_TAB01-ZTEXT02 = 'VVVVV'.

    APPEND IT_TAB01.

    *MODIFY ZYDTABLE01 FROM IT_TAB01.

    UPDATE ZYDTABLE01

    SET: ZTEXT02 = 'UPDATEDONE'

    WHERE ZTEXT01 LIKE 'BG1'.

    INSERT INTO ZYDTABLE01 VALUES IT_TAB01.

    IF SY-SUBRC = 0.

    COMMIT WORK.

    ELSE.

    ROLLBACK WORK.

    ENDIF.

    reward if useful..

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 16, 2007 at 03:37 AM

    Hi,

    The statement COMMIT WORK completes the current SAP LUW and opens a new one, storing all change requests for the current SAP LUW in the process. In this case, COMMIT WORK performs the following actions:

    It executes all subroutines registered using PERFORM ON COMMIT.

    The sequence is based on the order of registration or according to the priority specified using the LEVEL addition. Execution of the following statements is not permitted in a subroutine of this type:

    PERFORM ... ON COMMIT|ROLLBACK

    COMMIT WORK

    ROLLBACK WORK

    The statement CALL FUNCTION ... IN UPDATE TASK can be executed.

    ROLL BACK:

    The statement ROLLBACK WORK closes the current SAP-LUW and opens a new one. In doing so, all change requests of the current SAP-LUW are canceled. To do this, ROLLBACK WORK carries out the following actions:

    1) Executes all subprograms registered with PERFORM ON ROLLBACK.

    2) Deletes all subprograms registered with PERFORM ON COMMIT.

    3) Raises an internal exception in the Object Services that makes sure that the attributes of persistent objects are initialised.

    4) Deletes all update function modules registered with CALL FUNCTION ...IN UPDATE TASK from the VBLOG database table and deletes all transactional remote Function Calls registered with CALL FUNCTION ... IN BACKGROUND TASK from database tables ARFCSSTATE and ARFCSDATA.

    5) Removal of all SAP locks set in the current program in which the formal parameter _SCOPE of the lock function module was set to the value 2.

    6) Triggers a database rollback, which also ends the current database-LUW.

    Add comment
    10|10000 characters needed characters exceeded