‎2013 Oct 19 3:22 PM
Hi Team,
i have some doubt in Bapi with commit work.
suppose let we take the bapi "BAPI_EQUI_INSTALL" is called and after that commit work is called.
the equipment change will happen after commit work. But i cant understand what is happening inside commit work. firstly, if we want to insert some values in data base table why cant you use insert statement directly? secondly, if commit work does insert process where will the temp data gets stored so this statement can update the values in database tables after executing BAPI?
i have a issue that after calling this FM
call function module 'BAPI_EQUI_INSTALL'
commit work and wait.
there is some thing happening inside this Fm and after commit work the database tables gets updated. i dont know how it is happening and is there any custom code there to update the values? how can i proceed with this issue? can any one help me with this please? what should i debug either BAPI or COMMIT WORK?
‎2013 Oct 19 4:57 PM
Hi Dinesh,
Why u used exernal commit instead of BAPI_TRANSACTION_COMMIT? and check this thread for clarity http://wiki.scn.sap.com/wiki/display/ABAP/BAPI_TRANSACTION_COMMIT+versus+COMMIT+WORK
I hope you could understand the usage of BAPI COMMIT.
Regards,
Venkat.
‎2013 Oct 20 6:33 AM
firstly, if we want to insert some values in data base table why cant you use insert statement directly?
The Open SQL statements like INSERT / UPDATE / DELETE are part of DML (Data Manipulation language) i.e. they are used to manipulate data in the database table.
During the program execution, when these statements (like INSERT) is executed, it sends command to the database server (like Oracle / DB2 etc.) to update the data into database table.
However, the statement INSERT does not tell the database - when it should start the changes.
This is the task of statement COMMIT WORK. When the ABAP runtime reaches COMMIT WORK in the program, it ends the current SAP LUW of the program and is also a trigger for Database to initiate the changes.
Reason - why data is not inserted directly with the execution of INSERT statement.
You should check out SAP documentation
The reason is simple - when you have a large application like Create Sales Order (VA01), which updates a number of tables when a Sales Order is created in the system; so, you would need save data consistently in the system i.e. if there are 10 tables that should be updated, then either all 10 tables should be updated or if one of them fails then all other entries should also be rolled-back.
Regarding BAPI:
Any BAPI (BAPI_EQUI_INSTALL) is an API, which contains logic on how to create the data (what tables should be updated and with what values). So, BAPIs will contain INSERT/UPDATE statements.
But, BAPIs do not contain COMMIT WORK statement (which triggers the database update).
Check this out to understand why BAPIs do not contain COMMIT WORK
‎2013 Oct 21 6:44 PM
Hi Saurabh,
ok, if it is so, then for the normal programs why we are not using commit after every INSERT/UPDATE statements. But those are successfully updating the database right?
i cant understand why we need commit work, as far as i understood, as there are dependency among tables we are using commit to update it all at a time if no error found in return parameter. but as you said we may use INSERT/UPDATE inside a BAPI then it should update the values in database with out using commit work statement.
Then coming to my case mentioned in abaove BAPI:
a field "START DATE" of the work order is getting changed after the BAPI_TRANSACTION_COMMIT. In this where i should debug to find out from where this is getting updated? either in BAPI_EQUI_INSTALL or in BAPI_TRANSACTION_COMMIT FM?
‎2013 Oct 21 6:53 PM
I think the answer is in the comment about LUW's. If there is an explicit start transaction/end transaction or equivalent, I do not believe that you would want (or should) issue a direct INSERT/UPDATE before the BAPI (or external COMMIT) work is executed.
This is all about data integrity across tables. If a specific BAPI is being extended to add more
data to an existing table the BAPI manipulates, then there should not be a need for a separate
insert/commit work.
If you are adding data to another table, perhaps a Z-table, then it seems this would best be handled
AFTER the standard BAPI is called and is successful, to ensure your Z-table stays in sync with the other tables that might get updated by the standard BAPI.
You haven't really described the situation/scenario, so the "right" answer is a bit of challenge without some additional context.
** Above statements are my own interpretation, your use of them is at your own risk **