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: 

Problem in lock Sales order create with BAPI BAPI_SALESORDER_CREATEFROMDAT2

0 Kudos

Hi All,

i have the z program to create the sales order with reff quotation in SD With BAPI BAPI_SALESORDER_CREATEFROMDAT2.

this program will excute every 30 mins .

Problem: Some times if i excute the program in background it is taking morethan 30mins so second batch excution also gets starting to create the sales order for same quotation then it is creating 2 sales orders at atime with 1 quotation.

here i am getting duplicate sales orders so i want to lock the creation of duplicate sales order.

3 REPLIES 3

Former Member
0 Kudos

Hi,

How you are fetching the Quotation which should will be passed to the BAPI to create the Sales Order.

If it is based on the creation date and time of quotation, then always fetch the quotation which are created 30 mins back to the start of the background processing of your Z report.

Regards,

Harish

0 Kudos

Hi,

thanks for reply. I am fetching like that only but not working.

is there any way to lock the sales order creation if already processing to create sales order for same quotation

raymond_giuseppi
Active Contributor
0 Kudos

Some solutions

- Just lock (ENQUEUE) any object at the start of the job(*), if not locked, you can exit or wait in a loop, will be released at end of job (use a _SCOPE '3' so commit work wont release the lock)

-> This will insure the job runs only once at a time

- Lock the quotation before calling the BAPI, will be released by the COMMIT_WORK (from where do you fetch the quotation, if it is a customer Z_table, you can use the lock object that you have surely created ?) (use a _scope '2')

-> This will insure that at most one job will convert a quotation (i suppose you set a "done" flag or status in the quotation record)

Read [SAP Locks |http://help.sap.com/abapdocu_70/en/ABENSAP_LOCK.htm] if you are not familiar with the concept of lock in SAP.

Regards,

Raymond

(*) E_TABLEE for table, E_TRDIR for program, anything not required by another process