Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
biswanath_guha
Explorer
0 Kudos

Introduction:  SAP Workflow runs on ABAP Class / BOR object. So multiple instances can be created in SAP workflow. If the multiple workflow instances demand for a same resource at the same time, results deadlock between instances.  Suppose if three workflow instances (WF1, WF2, WF3) want to update Database approximately same time (t1 < t2 <=t3 respectively), then only WF1 who enters in t1 time can update DB. WF2 and WF3 will see it is already locked by first instance WF1. The below example of Goods Movement where BAPI BAPI_GOODSMVT_CREATE is invoked.

Problem description: Suppose inside workflow the goods movement BAPI BAPI_GOODSMVT_CREATE has been invoked to change the asset correct plant and storage location. Lets say, 3 workflow instances (WF1, WF2, WF3) has been triggered at the same time and approximately at same time (t1<t2<=t3 respectively) they arrived together at the step of goods movement. Then the BAPI BAPI_GOODSMVT_CREATE locks the material of the plant, so other two instances WF2 or WF3 were starving to lock it. In the mean time WF2 and WF3 fails to lock the same material. It returns the message “The plant data of the material ABCD is locked by the user WF-BATCH”.

Solution:  Step 1.  Use enqueue function module (ENQUEUE_E_TABLE) with below parameters

a.      ‘mode_rstable’ with exclusive lock ‘E’

b.      tabname = ‘EQUI’ ( Equipment master data table )

c.       ‘varkey’  =  Material number (MATNR)

d.      ‘_wait’  =  ‘X’

Each workflow instance will check if the material is free or not. If not it will wait for a while and then it will execute next step.

Step 2. Call BAPI BAPI_GOODSMVT_CREATE by passing required data and use BAPI BAPI_TRANSACTION_COMMIT with ‘wait’ as ‘X’.

Step 3. Use dequeue function module (DEQUEUE_E_TABLE) table EQUI with material number (MATNR).

a.      ‘mode_rstable’ with exclusive lock ‘E’

b.      tabname = ‘EQUI’

c.       ‘varkey’  =  material number (MATNR)

Conclusion:  The approach will assure that no workflow instance will fall into deadlock as well as it will execute the critical section successfully. Goods movement will be done successfully for multiple workflow instances.

Labels in this area