‎2007 Jun 06 6:31 PM
Hi Friends!
Can any one explain with example where to use commit & rollback
Looking for your help
Rahul.
‎2007 Jun 06 6:48 PM
you have one custom table
data : i_itab like ztest occurs 0 with header line.
start-of-selection.
assume that you have data in internal table
commit work.
modify ztest from table i_itab.
other program :
data : i_itab like ztest occurs 0 with header line.
start-of-selection.
assume that you have data in internal table
rollback work.
modify ztest from table i_itab.
see the results in database table on each step
‎2007 Jun 06 6:36 PM
COMMIT and ROLLBACK are closely related to LUW(Logical Unit of Work). What this means is that all tables are updated successfully or none at all. This helps with data consistancy and integrity. Here is some light reading on the subject.
http://help.sap.com/saphelp_nw70/helpdata/en/41/7af4bfa79e11d1950f0000e82de14a/frameset.htm
Regards,
Rich Heilman
‎2007 Jun 06 6:36 PM
Hi,
Please check this Uwe's reply from other thread with sample code.
BAPIs are indeed a good example to explain the use of commit work and rollback. BAPIs are RFC-enabled function modules that allow us to access SAP business objects (e.g. materials) from outside.
In case of failure BAPIs do not raise any exceptions but usually return the collected messages in a TABLES parameter RETURN (of line type BAPIRET2).
After calling a BAPI you have to evaluate the returned messages:
DATA:
lt_return TYPE BAPIRETTAB (table type of BAPIRET2).
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
...
IMPORTING
...
TABLES
...
return = lt_return.
LOOP AT lt_return TRANSPORTING NO FIELDS
WHERE ( type CA 'AEX' ). " (A)bort, (E)rror, X=dump
EXIT.
ENDLOOP.
IF ( syst-subrc = 0 ).
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'. " synchronous
ENDIF.
Please note that BAPIs may or may not return a Success message (type='S') in case of success. An empty RETURN messages indicates a successful BAPI call.
Regards,
Ferry Lianto
‎2007 Jun 06 6:48 PM
you have one custom table
data : i_itab like ztest occurs 0 with header line.
start-of-selection.
assume that you have data in internal table
commit work.
modify ztest from table i_itab.
other program :
data : i_itab like ztest occurs 0 with header line.
start-of-selection.
assume that you have data in internal table
rollback work.
modify ztest from table i_itab.
see the results in database table on each step
‎2007 Jun 06 7:06 PM
Hi Seshu!
Pls tell me the output of the above program its sounds intresting
‎2007 Jun 06 7:17 PM
Hi Rahul,
comments are in bold
you have one custom table
data : i_itab like ztest occurs 0 with header line.
start-of-selection.
assume that you have data in internal table
commit work. " <b>When you use commit work ,it will update the data sucessfully</b>modify ztest from table i_itab.
other program :
data : i_itab like ztest occurs 0 with header line.
start-of-selection.
assume that you have data in internal table
rollback work. " <b>It will not update the data even you use modify command because rollback.</b>modify ztest from table i_itab.
see the results in database table on each step
‎2007 Jun 06 7:33 PM
Seshu!
Thank u very much
I have one more doubt can u tell me commit and rollback can be used in bdc if yes, can u pls tell me a eg where to use it.
Rahul.
‎2007 Jun 06 7:34 PM
Seshu!
Thank u very much
I have one more doubt can u tell me commit and rollback can be used in bdc if yes, can u pls tell me a eg where to use it.
Rahul.
‎2007 Jun 06 7:36 PM
commit and rollback - should not use in BDC
in call transaction - there is option ( if you use UPDATE 'S' ) then this will work as commit.
‎2007 Jun 06 7:37 PM
‎2007 Jun 06 7:41 PM
‎2007 Jun 06 7:43 PM
‎2007 Jun 06 7:46 PM
Hi Seshu!
It is onley used in bapi's thats all apart from that where it is used
‎2007 Jun 06 7:58 PM
We do not use commit work in bapi,we use FM BAPI_transaction_committ after bapi fm .
‎2007 Jun 06 8:05 PM
Ok Thats Right!
We use FM in BAPI Thats right i want to know commit & Roll back where it is used
Pls Reply Friend
Rahul.
‎2007 Jun 06 8:18 PM
Hello Rahul,
We will not use comitt work in BAPI or BDC,
some times we have direct updation to custom tables,then we use comitt work or roll back.
in the selection-screen we have
option like test mode ,update mode.
when the user choose test mode we will not update database ( Here we use Roll back) and also when ever we have error updating one table and
again we are updating one more table ( In this case if first table updates then need to update second table,otherwise should not update
when the user choose update mode we will update database table ( here we use committ work )
‎2007 Jun 06 8:47 PM
Hi Seshu!
Thank u very much i am clear with the concept.
Regards
Rahul.