‎2008 Jul 04 2:01 PM
hi gurus
bapi_transaction_commit is used if the BAPI is success.
bapi_transaction_rollback is used if the BAPI is failed
could u plz explain this with a simple example which uses both the above BAPI
‎2008 Jul 04 2:09 PM
Hi
After calling a BAPI u should check the return table with the messages:
If there's a message type E or A it means the BAPI fails, else the BAPI works:
CALL FUNCTION 'BAPI.........'
EXPORTING
..................................
IMPORTING
..................................
TABLES
return = return
..................................
LOOP AT RETUNR WHERE TYPE = 'E' or TYPE = 'A'.
EXIT.
ENDLOOP.
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.Anyway u should consider it doesn't usually need to use BAPI_TRANSACTION_ROLLBACK, because if the BAPI fails it shouldn't update any database tables.
BAPI_TRANSACTION_ROLLBACK should be usually done if u need to create a flow where several BAPIs are called and if at least one BAPI fails it needs to reset all updating made by previous BAPIs.
I'm not sure it needs call it for only single BAPI.
Max
Max
‎2008 Jul 04 2:06 PM
Diana,
BAPI_TRANSACTION_COMMIT
____________________________________________________
Short Text
Execute external Commit when using BAPIs
Functionality
This method executes a COMMIT WORK command. It is required for transactions developed outside the SAP system that change data in the SAP system by using BAPI calls.
When you call BAPIs in your program that change data in the SAP system, you must then call this method to write the changes to the database.
Notes
Messages are returned in the parameter 'Return'. The documentation for this parameter contains the return values and their meanings.
Further information
Use the method BapiService.TransactionRollback to prevent changes to the database being committed.BAPI_TRANSACTION_ROLLBACK
____________________________________________________
Short Text
Execute external Rollback when using BAPIs
Functionality
This method executes a ROLLBACK WORK command. It is required for transactions developed outside the SAP system that change data in the SAP system by using BAPI calls.
If you call BAPIs in your program that change data in the SAP system, this method can prevent these changes being written to the database. The prerequisite is that these changes have not already been transferred to the database with a COMMIT WORK command.
Notes
Messages are returned in the parameter RETURN. The documentation for this parameter contains the return values and their meanings.
Further information
The method BapiService.TransactionCommit can write data changes made using BAPI calls to the database.Amit.
‎2008 Jul 04 2:09 PM
Hi
After calling a BAPI u should check the return table with the messages:
If there's a message type E or A it means the BAPI fails, else the BAPI works:
CALL FUNCTION 'BAPI.........'
EXPORTING
..................................
IMPORTING
..................................
TABLES
return = return
..................................
LOOP AT RETUNR WHERE TYPE = 'E' or TYPE = 'A'.
EXIT.
ENDLOOP.
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.Anyway u should consider it doesn't usually need to use BAPI_TRANSACTION_ROLLBACK, because if the BAPI fails it shouldn't update any database tables.
BAPI_TRANSACTION_ROLLBACK should be usually done if u need to create a flow where several BAPIs are called and if at least one BAPI fails it needs to reset all updating made by previous BAPIs.
I'm not sure it needs call it for only single BAPI.
Max
Max