‎2005 Dec 29 7:26 PM
hi all,
i developed a custom transaction in which i am doing several database updates. i want these to take place like standard SAP LUW all or none changes.
what has to be done to accomplish this..
presently i have something like this:
update xxx .
commit work.
update yyy.
commit work.
call 'z_bapi_xxx' in update task.
call function 'bapi_transaction_commit'.
thanks..
‎2005 Dec 29 7:51 PM
If you put commit work after every table then it will commit till that time and if something goes wrong later the previous one will not rollback.
So, you have put commit work after all. so that it will either commit all or rollback all.
‎2005 Dec 29 7:51 PM
If you put commit work after every table then it will commit till that time and if something goes wrong later the previous one will not rollback.
So, you have put commit work after all. so that it will either commit all or rollback all.
‎2005 Dec 29 8:11 PM
you can issue commit work after every logical point you want to save data.
‎2005 Dec 29 8:47 PM
Hi,
usually you do not need any COMMIT WORK in your program, because at the end of the program run, a commit work is issued automatically and all data are stored in the database.
If the program ends with an error (message type E, A, X), the data are rolled baxk and nothing is stored.
But note: Any interruption of the program flow (also and especially online acreen input) will do a commit work too.
And there are exceptions: Any PERFORM ... ON COMMIT will need an explicit COMMIT WORK. The auto commit work will not trigger PERFORM ON COMMIT. Thats why you have to do a COMMIT WORK explicitly after calling any updating BAPI modules.
The best and safest and most efficient way is always to do as SAP does:
Put all to-be-stored data into internal tables. At the end of your transaction, if everything is fine, call a function module IN UPDATE TASK. Create this function module as an UPDATE module, the interface should have all your internal tables. In the module, just do the necessary updates and inserts.
After the CALL FUNCTION ... IN UPDATE TASK
issue the COMMIT WORK.
regards,
C.
‎2005 Dec 30 10:35 AM
Hi KP,
Keep your code sequence like this.
Update XXX.
Update YYY.
Commit Work.
Call 'Z_BAPI_XXX'.
Call 'BAPI_TRANSACTION_COMMIT'.
Thanks,
Sreekanth G
‎2005 Dec 30 10:39 AM
If your BAPI has RETURN table..
CLEAR V_ERROR.
LOOP AT RETURN WHERE TYPE = K_E OR
TYPE = K_A OR
TYPE = K_X.
MOVE K_X TO V_ERROR.
EXIT.
ENDLOOP.
IF V_ERROR IS INITIAL.
*-- BAPI COMMIT
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
*-- BAPI ROll BACK
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK.
ENDIF. " V_ERROR is initial
Thanks,
Sreekanth G