Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

.NET Connector BAPIs and CommitWork and Wait

Former Member
0 Kudos
571

Hi,

I am experiencing timing issues calling Bapi_Salesorder_Change immediately after executing Bapi_Salesorder_Createfromdat1 in a .NET Connector v2.0 environment.

Bapi_Salesorder_Change returns an error that the sales order does not exist (yet) and therefore fails updating the data. I suspect transaction commit has not yet completed in the SAP system of the Bapi_Salesorder_Createfromdat1 call since this error only occurrs sporadically (s. )

Since there is no support for CommitAndWait in .NET Connector v2.0 (s. ) I wonder what the best implementation strategy is in this case ?!

Is there a possibility to use a "SET UPDATE TASK LOCAL" approach from the .NET Connector ?

Thanks for any hints,

Andreas Koschinsky

1 ACCEPTED SOLUTION

christian_wohlfahrt
Active Contributor
0 Kudos
343

Hi Andreas,

as Reiner proposed in one of your links: copy FM bapi commit and call this z-function explicit with wait = 'X'.

If this won't help in all cases (normally it should!), then add a select for you new sales order in between. If this is successfull, go on - otherwise wait up to n seconds, next select...

Regards,

Christian

P.S.: Which change can't be done in creation?

4 REPLIES 4

christian_wohlfahrt
Active Contributor
0 Kudos
344

Hi Andreas,

as Reiner proposed in one of your links: copy FM bapi commit and call this z-function explicit with wait = 'X'.

If this won't help in all cases (normally it should!), then add a select for you new sales order in between. If this is successfull, go on - otherwise wait up to n seconds, next select...

Regards,

Christian

P.S.: Which change can't be done in creation?

0 Kudos
343

Hi Christian,

thanks for your answer: Problem is that Reiner stated that this function has been explicitly disabled in .NET Connector 2.0 (s. : Mr.

Reiner Hille-Doering "because it can - wrongly used - cause deadlocks that bring your SAP system in an unusable state" - but he did not explain what "wrongly used" means...)

I did some test implementations using "Bapi_Transaction_Commit"

(1) DOES not work consistently, because Createfromdat1 Transaction might not be

completed when Change is called

Bapi_Salesorder_Createfromdat1(..) with WithOutCommit = " "

Bapi_Salesorder_Change()

Bapi_Salesorder_Change.CommitWork

(2) DOES work consistenly in test environment

Bapi_Salesorder_Createfromdat1(...) with WithOutCommit = "X"

Bapi_Transaction_Commit("X", ...)

Bapi_Salesorder_Change()

Bapi_Salesorder_Change.CommitWork

I'll probably use The "GetStatus()" wait loop, though this is not my favourite coding style

Greetings,

Andreas

P.S. I am using Bapi_Salesorder_Createfromdat1 wich does not support TEXT updates for sales order positions (s. )

0 Kudos
343

Hi Andreas!

Maybe 'wrongly used' is to try a change without checking the status before. Then two processes try to get a lock on this order.

I would propose an explicit commit work and wait call and a loop for waiting. Restrict the loop to a fixed number, don't try to often (not more often than once a second, if there is a really long update queue, you might have to wait a minute -> every 5 or 10 seconds is good, too).

I guess you would prefer a deadlock and an information of problem by system instead of missed updates from time to time.

Regards,

Christian

0 Kudos
343

Hi Christian,

yes - I have implemented this strategy now. I parse the message number of the return data structure of the Bapi_Salesorder_Change function and if "number" is "302" (which stands for "sales document not found") I retry x times with y ms to wait between the calls.

A more elegant solution might be as dennis proposed (s. - sorry posted this question twice, first in the wrong forum) but I wanted to avoid introducing a new user defined rfc function.

Greetings,

Andreas