Enhance SAP EWM
Latest Starting Date (LSD) Calculation
I closed my blog about the standard calculation of the LSD with the option to change the result manually. I guess you all know that this can easily done via the warehouse monitor. FM /SCWM/RSRC_WO_LSD_CHANGE_MON takes care to write the update in all relevant tables.
This is a feature you or the warehouse supervisor might want to use in exceptional cases to prioritize one WO over the other (e.g. you get a last-minute high-priority order which should be processed earlier as usual).
This should not be the topic of this blog post though. In this tutorial you will learn about a bunch of different options that SAP EWM offers to manipulate the standard way of calculating the LSD with custom coding.
As with all my other suggestions about how to change the standard code I will only consider options given via clean enhancements spots to ensure that whatever coding you implement will survive future release updates from SAP.
To provide structure to this post, we’ll once again refer to the formula highlighted in my previous discussion on this topic. Please note that this post builds on the concepts covered earlier, so I recommend reviewing the previous post if you haven’t already, as I won’t be re-explaining the basics.
We learned before that EWM is using this formula to calculate the LSD:
LSD = WO due date – (planned execution duration + planned movements duration)
That also means that to change the calculation of the LSD, we can implement a logic that either changes the standard result directly, or that changes the approach for calculating the different components of the formula. Thus, I structured this article in the following way:
- Options to enhance the WO due date calculation
- Options to enhance the (planned execution duration calculation
- Options to enhance the planned movements duration) calculation
- Options to enhance the result of the standard LSD calculation directly
Notes
- I am sure that I did not identify 100% if the possibilities but I am optimistic that I found the most important ones for each of the 4 categories listed above!
- As with my previous article about the LSD calculation, I decided to take everything related to the Labor Management out of scope. The article would simply become too long and I assume most of you are not using LM anyways. At some point I might go for a separate post about LM in this context specifically.
Options to change theĀ WO due date
Of course you can change the planned departure date in the Mapin Badi which will have an impact on the LSD calculation if you are working without waves. But I think nobody will change the delivery dates & times of a warehouse request only to get a different LSD in the corresponding WOs. Thus, no obvious option for me to change the due date in case you are not working with waves.
If you are working with waves you can make use of Badi /SCWM/EX_WAVE_SAVE to change the wave header data while saving. Relevant for the LSD calculation are completion dates of the separate steps (see my blog post about the LSD calculation for further details). Usually (not always) those timestamps are inherited from the wave template. By overwriting them, you can influence the LSD in one way or the other (e.g. moving the pick completion date from the wave header further into the future will also lead to a later LSD in the corresponding WOs).
Options to change theĀ planned execution durationĀ calculation
Badi /SCWM/ES_CORE_WT_RT gives you the option to overwrite the execution duration which had been calculated and summarized by the standard logic for the source and destination bin. When you increase the execution duration with a custom logic you will end up with an earlier LSD (remember the formula above).
*Ā Ā Ā Ā Ā Ā Ā WithinĀ thisĀ BAdiĀ methodĀ theĀ userĀ hasĀ theĀ possiblityĀ toĀ overwrite
*Ā Ā Ā Ā Ā Ā Ā theĀ reachĀ timeĀ basedĀ onĀ variousĀ parameters.
*Ā Ā Ā Ā Ā Ā Ā TheĀ resultingĀ reachĀ timeĀ willĀ beĀ convertedĀ toĀ theĀ timeĀ unit
*Ā Ā Ā Ā Ā Ā Ā ofĀ theĀ warehouse.
Options to change theĀ planned movements durationĀ calculation
The movement duration can only be manipulated while using option 2 for the travel distance calculation (the ‘new’ way for the calculation which has to be activated on warehouse number level > check my blog post about the LSD calculation if you are not familiar with the two different options here).
Badi /SCWM/EX_TDC_START can be used to implement your own distance calculation algorithm. The Badi is called from method /SCWM/CL_TDC-CALC_DISTANCE (in fact the standard calculation of the distance is sitting in an example implementation of this Badi – you can copy the fallback class and use the adjusted copy in your Badi implementation). Increasing the distance will increase the movement duration which will result in an earlier LSD (remember the formula above):
Once the distance has been calculated, Badi /SCWM/EX_TDC_BRF_CALC_TIME can be used to calculate the travel time. Again, the standard logic is sitting in the example implementation. Again, you can copy the fallback class and use the adjusted copy in your Badi implementation. Increasing the travel time will result in an earlier LSD (remember the formula above):
Options to change the result of the standard LSD calculation directly
The most important Badi here is /SCWM/EX_RSRC_PROC_WO, which can be used to simply overwrite the result of the standard LSD calculation. Of course this Badi is only called in case FM /SCWM/RSRC_WHO_CREATE is executed, which is only the case if the WO is assigned to a resource management relevant queue.
This Badi is called to update the standard calculation before it is being saved to the DB the first time. In addition to this, you have an option to update the LSD at an even later point in time. Badi /SCWM/EX_CORE_CO_POST gives you a possibility to update the LSD of WO X, with the confirmation a WT from WO Y. An example implementation is given with class /SCWM/CL_EI_CORE_POST_CONS_WHO which can for instance be used to synchronize the completion of WOs which are processed in different activity areas. I wrote a detailed blog post about this feature a while ago (you can also find it on Youtube).
Last but not least – and worth it to mention here – SAP provides an API to change the warehouse order header data from any kind of custom logic, sitting with EWM or in some kind of custom/non-SAP software.
Class /SCWM/CL_API_WHSE_ORDER, method /SCWM/IF_API_WHSE_ORDER~UPDATE:
To conclude this post, as promised in my blog about LSD calculation, we will take a small step away from classical deliveries as warehouse requests towards production material requests.
Most of the options listed above are not applicable for PMRs. However, Badi /SCWM/EX_MFG_STAGE_WT_SO provides the option to set the pick completion date during staging WT creation. This date will later be used to calculate the due date and the LSD, particularly if you are working with a single-order staging approach. If you are working with cross-order staging, you can use Badi /SCWM/EX_MFG_STAGE_WT_CO.
SAP provides an example implementation of the single-order staging Badi (class /SCWM/CL_EI_MFG_STAGE_WT_SO), which includes logic to set the LSD based on the requirements date. This date is determined in the ERP system for the production order components and is mapped to the EWM date type SCMPREQ of the PMR item:
Not that the approach for the determination of the LSD based on the requirements date will not work that easily in case you are working with a cross-order staging approach. You can indeed use the Badi that I mentioned before and implement a similar logic but you will have to implement an additional Badi to end up with the same result. Cross-order staging WTs do not have a reference to a specific PMR item, which would be required though in case you want to read the requirements date based on this reference. One option is to /SCWM/EX_MFG_STAGE_INFO before to link the PMR item data to the staging item/task. Shoutout at this point to Ales Knor from advisio.tech who drew my attention to this!
That wraps up my review on enhancing the LSD calculation. I’ve outlined various options for you to jump in at different stages, and I’m confident that one of these approaches will meet your project’s specific requirements for calculating LSD!