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: 

WAIT UP TO...In background job

Former Member
0 Kudos

Hi,

I am running BDC for F-04 to cear and post the documents. There i put WAIT UP TO 3 SECONDS after creation of every document as it was throwing the error 'Transaction F-04 is currently blocked by the same user running the program'.

But suppose I am clearing and posting large number of documents then it is taking time. Suppose I clear and post 200 docs then will there be a delay of 600 seconds when it'll run in the background ? If we consider straightforward calculation in background as 200*3 = 600.

What would be the best solution to avoid above error and how much the WAIT should I place ?

Thanks.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

Try to temporarily lock the transaction required object (transaction, account ?), analyze with SM12 to find the lock object used and the function module * ENQUEUE_ associated. Call this module with the WAIT option, if necessary in a DO / ENDDO loop. once locked object, release it with the DEQUEUE_ *function module and run the following CALL TRANSACTION.


Yoyu could also read  1802551 - Error message F5287 "Account & & is currently blocked by user &" when posting and/or clear...if that is the correct error message ?


Regards,

Raymond

10 REPLIES 10

Former Member
0 Kudos

Hi,

Haven't u tried any BAPIs?

0 Kudos

Hi,

I am not using any Bapi but using call transaction for F-04.

Can i avoid this error of user locking by avoiding wait?

Thanks

former_member182354
Contributor
0 Kudos

Hi,

    Use below BAPI to do your code and you will not face this issue.

BAPI_ACC_DOCUMENT_POST.

Raghav

0 Kudos

Hi,

If i can't use this bapi then what could be the alternative to avoid this issue.

Thanks.

0 Kudos

Then try out what Raymond says.

BAPI's are always the best way to do this.

raymond_giuseppi
Active Contributor
0 Kudos

Try to temporarily lock the transaction required object (transaction, account ?), analyze with SM12 to find the lock object used and the function module * ENQUEUE_ associated. Call this module with the WAIT option, if necessary in a DO / ENDDO loop. once locked object, release it with the DEQUEUE_ *function module and run the following CALL TRANSACTION.


Yoyu could also read  1802551 - Error message F5287 "Account & & is currently blocked by user &" when posting and/or clear...if that is the correct error message ?


Regards,

Raymond

0 Kudos

Hi Raymond,

I have gone through that SAP Note, I am getting the same error if I don't put WAIT after creation of one document. Note is saying that SAP itself locks few FI transactions including F-04 to avoid postings in same GL from different/same users. If this facility is available then where exactly I should use lock object ?...If I am using wait in the lock object then It'll again increase delay.

Can't COMMIT WORK AND WAIT works similarly as wait up to?...Can I use that instead ?

Thanks.

0 Kudos

A COMMIT-WORK AND WAIT will actually wait until every update task is executed and so every lock kept in those task is released, BUT () only if executed in the luw/program that called the update task, so it will be of no interest at all to execute such a commit after a CALL TRANSACTION (*), it can be used when you called a BAPI.

Try to analyze the locks with SM12 (or analyzing standard code or error log during tests) during the transaction execution and then identify the ENQUEUE (**) FM as I wrote in previous answer.

Pseudo-code


Loop

if new vendor/customer is same id than previous one

  try to lock vendor/customer with wait option in a do/enddo loop until successful, you can limit iterations in case of severe performance problem

  release lock

end if

create BDCDATA

execute transaction

memorize last vendor/customer

End of loop

Regards,

Raymond

(*) The transaction will have raised a COMMIT without WAIT option itself before your driver program...

(**) The "applicant" FM are listed in the note, e.g. ENQUEUE_EFKNB1A

muneshpatwari
Active Participant
0 Kudos

Hi,

Instead of wait up to..., you can try using "COMMIT WORK AND WAIT".

Regards,

Munesh.

Former Member
0 Kudos

Hi,

try this CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.