In event linkage setting, there are two scenarios for which we had made entries. The first one is for order replenishment logic and second one is order gate (customer forecasting) logic.
Tcdoe: SWLD Utlities->Events->Linkage Object Event Reciever FM BUS2032 Created ORDERREPLEN BUS2032 Created ORDERGATE
For both FM, we are using BAPI for updating the sales order which is 'BAPI_SALESORDER_CHANGE.
The problem is that when the sales order is created from IDoc, events get triggered for both scenarios. Before completing ORDERREPLEN, ORDERGATE is coming and checking for same sales order and finding it locked and all the forecast checks for customer are failed.
NOTE: As per client standard, I can't use WAIT command in FM, so I need to check with you. Is there any other way to handle the locking issue?
I also wonder if there is a way so that we can say which FM will process first when we put serialization in event Linkage/Workflow for the same business object.
1. Consider whether it is correct for both events to trigger. You can always use a Check Function Module to prevent a particular event from being raised. Of course this all depends on whether you can detect this condition. Perhaps there is some indicator on the business object (or table which you could add) which indicates that this was processed from the IDoc.
2. Even if a lock does occur, why does your workflow fail? Enqueue errors should be modeled as temporary exceptions on the methods. Thus, when they are raised, the workflow will automatically retry the step after waiting 5 minutes (or what ever your system setting is). Usually this try, retry approach takes care of locking issues.
3. You could always deliver one of the events to the event queue. This will delay the delivery of this event and thus resolve your locking issue.
Dig Deeper on SAP workflow development
Related Q&A from Alon Raskin
An SAP user has created a user decision step in an SAP workflow item and wants to know how an end user can send an attachment to other users. Continue Reading
A SearchSAP.com reader wants to know how to hide the forward button in an SAP Business Workplace toolbar. Continue Reading
Find out how to automatically replace an SAP workflow item when a user hits "cancel" so that the workflow item re-appears to all possible agents. Continue Reading