‎2013 Jun 05 12:23 PM
Hi Experts,
I have a program with calls a normal function module (NOT update task). Inside this FM, there are Insert / Update / Delete performed on database tables.
After this function module, we call 'COMMIT WORK AND WAIT'. The issues is all records are not updated in DB, when I click on 'back' button immediately after button 'save'.
I cannot check in debugger since, when I give it some time, all records are saved correctly.
Flow is:
- Select some items (say 40), do some change.
- Click on button 'SAVE':
...
Call FUNCTION <xyz>.
COMMIT WORK AND WAIT.
...
- Immediately, Click on button 'BACK'.
--? sometimes, some records are not updated? (5 items are not updated)
How can this be corrected? Wouldn't WAIT, actually wait for COMMIT to finish?
Would it help to add - 'set update task local' or checking sy-subrc to be 0 (while loop) until 'commit work and wait' is finished?
‎2013 Jun 05 12:29 PM
Please explain the process in more detail...
Are you calling the FM <XYZ> for every record.
try adding WAIT UP TO sec Seconds after commit and see if it works...
‎2013 Jun 05 12:37 PM
No FM is called once for all collective records..
I do not want to add WAIT UPTO since, it will decrease performance. Any other option?
‎2013 Jun 05 12:35 PM
Hi Neetu,
CALL FUNCTION IN UPDATE TASK must be sufficient as it is one of the widely used options for updating the database entries in standard programs. Also, add a sub-routine for ROLLBACK using PERFORM <sub-routine> ON ROLLBACK so that you can know if the problem was with updating the database or with less time for updation.
Hope this helps,
~Athreya
‎2013 Jun 05 12:38 PM
Hi Neetu,
When we use commit work and wait---------the system will wait for all the process to be completed before updating in the database. This is like a Synchronous process.
Regards
Arun
‎2013 Jun 05 12:40 PM
Hi Neetu,
Are you updating single records with modify statement or the entire table at one go.
It is better to collect records to be updated and do it in one go.
Delete the records also in one go with a separate statement
Also use enqueue and dequeue to do updates in that way it is locked and updated.
Hope it helps
BR.
‎2013 Jun 05 12:43 PM
Hi,
several times I am getting this problem and the way I am resolving is..
for example : I need to create 1 document.
1. Call 'FM' " FM which will create the document
2. Call 'BAPI_Commit_transaction'
wait = 'X'
3. do 20 times.
select document from database.
if sy-subrc is initial.
exit.
endif.
enddo.
But I think you are changing some document, so in your case I'll suggest you to put
"Wait upto --- secs"
you can put the time limit according to your need.
‎2013 Jun 05 12:54 PM
Hi,
Just increase your wait in the program.
Also advisable is to do a DB commit calling the function module DB_COMMIT
Cheers,
Arindam
‎2013 Jun 05 1:55 PM
Also advisable is to do a DB commit calling the function module DB_COMMITCOMMIT WORK will end the LUW & trigger a database commit, IMO there is no need for an explict DB commit.
How can this be corrected? Wouldn't WAIT, actually wait for COMMIT to finish?Don't think so ... Actually COMMIT WORK AND WAIT waits for V1 updates(N.B.: local updates are synchronous by nature) to be completed.
Would it help to add - 'set update task local' No, unless you've some update procedures (Update functions, subroutines)
or checking sy-subrc to be 0 (while loop) until 'commit work and wait' is finished?No, unfortunately
The best bet would be to add a WAIT when the user clicks the back button.
BR,
Suhas
‎2013 Jun 05 1:16 PM
Hi,
Use this :
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
‎2013 Jun 05 1:43 PM
Hi Neetu,
Please add this line just before your call function.
SET UPDATE TASK LOCAL.
CALL FUNCTION <your_fuction_module>.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
then continue your query....
also see the documentation for set update task local.
Regards,
Mordhwaj
‎2013 Jun 05 1:44 PM
COMMIT-WORK AND WAIT will wait til the V1 (high priority) update tasks are executed, as there are no update task in your case, your AND WAIT serves no purpose (too sad...)
A call to FM DB_COMMIT could be sufficient, actually COMMIT-WORK will trigger such a Database commit, then there are delay, but relative to Database System Server, neither Abap nor Application Server, and then there will also be cache refresh delay between application server and database server.
So forget the AND WAIT option, and better perform a DO/SELECT/WAIT UP TO ENDDO loop to wait for database update, as you will never be able to know for sure the delay required, especially at peak times when servers are busy,
If the problem arise very often it may be time to upgrade server or better DB/cache optimization ?
Regards,
Raymond
‎2013 Jun 05 2:00 PM
One of the things that you might consider evaluating is whether all locks have been released. There are lock processes that can become overloaded and therefore delayed. This is testable in your code and would therefore allow you to manipulate your process with it.
Another thing, and this is anecdotal:
I have experienced thing that would indicate that the commit and wait is actually a queueing process. It waits until all commits have been successfully queued. If a large number have been queued, then these can be delayed while the queue clears.
Again, the second is only anecdotal and really needs factual support.
Finally, Are you sure that you are not exceeding the LUW? Say you were creating a documents. Each document is its own LUW, under normal conditions. The commit ends the LUW. If you wait for 10's or 100's of documents before commiting, then you over extend the LUW. This is not how the system is intended to work. Is there a chance that you are doing this?
Neal