on 03-15-2004 9:05 PM
Hi all,
working with <b>BAPIS</b> I usually have the same problem, when the BAPI generates a SAP document and after calling <b>BAPI COMMIT WORK</b>, with parameter <b>WAIT set to X</b>, sometimes the DataBase is not updated until the program is finished.
Imagine that I have to create a billing document via BAPI_BILLING_DOCUMENT_CREATEMULTIPLE, or another BAPI that creates a Billing Document in SAP, this BAPI returns a message table where I can see that the document xxxxx has been created, so, I call BAPI COMMIT WORK to update the record into the DataBase. But, sometimes, when I try to get information about the document created making a selection in VBRK table it returns SY-SUBRC = 4 (the document hasn't been updated yet) and so I can't get some information that is relevant to know.
To solve this problem I usually makes the next ABAP code, I know that it's not nice, but it works
<i>DO.
SELECT * FROM vbrk .....
IF sy-subrc is initial.
....
ENDIF.
ENDDO.</i>
I want to know if I'm doing something wrong, I'm sure that exist a nicier pice of code, or a standard process to be sure that the record is stored in the DataBase.
<b>Anyone knows it?</b>
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do not set WAIT = 'X' rather comment it or set it to SPACE in BAPI_TRANSACTION_COMMIT
Edited by: vijetasap on Oct 25, 2010 12:04 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jorge,
I found your post on SDN when searching for BAPI_BILLINGDOC_CREATEMULTIPLE on Google. Do you perhaps have an example of how to use the BAPI, or maybe some better documentation? The doc on the function is quite poor and the notes relating to it are of no use.
Thanks and Regards,
Martin Ceronio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Jorge
The problem you faced to has quite a simple solution. Before calling BAPI which causes asynchronous updates insert SET UPDATE TASK LOCAL statement. It turns on local update mode till next COMMIT. That is, all the updates will take place synchronously in the same task and after next COMMIT you can securely read all the updated/inserted records. Here you are:
SET UPDATE TASK LOCAL.
CALL FUNCTION 'BAPI_BILLING_DOCUMENT_CREATEMULTIPLE'
......
COMMIT WORK.
Also this code helps to avoid dead locks when you call the same BAPI in a loop.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sergei,
I am observing the same system behavior as described by Jorge even with SET UPDATE TASK LOCAL. I use different BAPI: sales order creation and in the same program sales order change. Sales order needs to be in the database before in can be change which is obvious but it is not there. The solution to this is similar to the one use by Jorge.
regards,
Andrzej
Hi Sergey korolev,
After seeing the solution given to the BAPI- Commit problem, I intend to ask you the similar problem which I am facing . I am using Call transaction IB02 to add few more components to the existing BOM equipment in synchronous mode and using COMMIT WORK AND WAIT after Call transaction Using .... statement to commit into database. After this satement when I use the FM CS_BOM_EXPL_EQU_V2 to retrieve all the BOM entries to disply whole BOM components, it does not show the newly added ones appended through above Call transaction. Request you to advise how to proceed in case of Call transaction also.
Hi, sorry that I am reviving this old topic, but I have very similar problem and I cannot solve it by SET UPDATE TASK LOCAL... It is also SD module.
In FM RV_INVOICE_REFRESH I created enhancement which expect entries in table KONV, which was created also during the same workflow, in which I call this FM, but not by me (so before it I cannot use SET UPDATE TASK LOCAL, because it is not my code and I even dont know where exactly are this records created), but by standard processing before RV_INVOICE_REFRESH is called.
The problem is, that sometimes SELECT from KONV returns no results. Before this select I am calling COMMIT WORK AND WAIT and then also in loop I am trying to select this records from KONV, but sometimes even this does not help. Is there any other way how to 100% commit work and be sure that changes are in DB and I can access them by standard select?
Now I tried to add DB_COMMIT call as somebody here advices, but I dont know if it helps.
Thanks.
Hi Jorge,
This doesn't make a lot of sense. COMMIT WORK AND WAIT will wait until all V1 updates and PERFORM ... ON COMMIT's are performed (it will return before V2 updates).
Now I'm not an SD developer, but I assume VBRK is the billing document header and thus the call to update it will not be in a V2 update function.
What exactly do you mean when you write "I call BAPI COMMIT WORK..."? Do you mean:
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
or
COMMIT WORK AND WAIT.
Perhaps it would be useful to post some more of your code?
Scott
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When I have written "I call BAPI COMMIT WORK..." I'm referring to FM 'BAPI_TRANSACTION_COMMIT'.
Here is a piece of code:
<i> call function 'BAPI_BILLINGDOC_CREATEMULTIPLE'
exporting
testrun = ' '
tables
billingdatain = it_bapivbrk
return = it_bapiret1
success = it_bapivbrksuccess.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
....... SOME PIECE OF CODE HERE ......
SELECT * FROM vbrk Where.....
</i>
<b>Sometimes</b>, after second FM, the SELECT sentence returns SY-SUBRC = 4 but the 'BAPI_BILLINGDOC_CREATEMULTIPLE' FM says that the document inside <i>it_bapivbrksuccess-bill_doc</i> has been created, a synchronization problem occurs because when I go to VBRK for read some data, the document is not created yet. When the program has been finished the record is stored in the DataBase.
SAP standard documentation about BAPIs says that after calling a BAPI is necessary to call 'BAPI_TRANSACTION_COMMIT' to update the DataBase, but sometimes it doesn't works.
I have heard somewhere that the function module DB_COMMIT also is used after BAPI_COMMIT_WORK.
Maybe you can try that.
regards,
Hans
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is odd, I would have expected that if commit work and wait is set, the database will be updated before the program continues the next statement. However, I could imagine, that a delay due to system load can occur.
With your coding you are on the save side, but you cause extra load by many unneccesary databse connects. So what I would suggest is, either to set a delay to avoid that many reads.
Annother idea is to check if you are able to enqueue the object in question. If so, the database should be ready to read on the table.
Christian
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.