During a recent implementation, we decided to take advantage of procurement with origin acceptance scenario in SAP.
SCN post Procurement with Origin Acceptance is really detailed and helpful document to start with. We decided to take this to a step further to tailor business requirement and decided to provide ability to post movement 107 automatically when planned goods movement date was maintained for the first time in the inbound delivery.
In this short document I intend to describe technical challenges faced and solution provided. I hope it would help consultants with similar requirement. Any suggestions for improvement are most welcome.
1) SAP provides BADI LE_SHP_DELIVERY_PROC for customized logic implementation during delivery save. Unfortunately calling BAPI_GOODSMVT_CREATE directly from this BADI does not help. This is because during call to BADI, delivery is already locked and BAPI tries to work on same delivery resulting into infinite loop inside the code and delivery will not be saved.
2) As a work around , I decided to create a subtype of SAP BO BUS2015 and added a new event FIRST_WADAT to this BO. This event was triggered using FM SWE_EVENT_CREATE_IN_UPD_TASK in method SAVE_AND_PUBLISH_DOCUMENT of BADI LT_SHP_DELIVERY_PROC.
3) I created a custom single step workflow and liked it to the event FIRST_WADAT. In workflow , single step of creating movement 107 using BAPI_GOODSMVT_CREATE was incorporated. Reason for using workflow over single step task was the ability to restart workflow using SWPR.
4) Log for 107 movement creation was included in an application log visible to user via transaction SLG1.