domingo, 6 de agosto de 2023

SAP S/4HANA 2022: New BAdI to influence MRP elements in MRP Live and Classic MRP

 SAP S/4HANA introduced the new BAdI PPH_SUPPLY_DEMAND_LIST, which allows us to change, add or exclude MRP elements from the MRP run in both MRP Live and Classic MRP. This BAdI is also called in MRP evaluation transactions (such as MD04) and the MRP Cockpit Fiori Apps. This blog provides more details about this BAdI, explaining why it was created and the benefits of using this BadI.

 

Manipulating MRP elements using BAdIs

Influencing MRP elements is a very common requirement for companies running MRP, and very often enhancements are implemented to make a specific element not relevant to MRP, or to change specific attributes of an MRP element, such as date and quantity.

In the old ECC world, we could use BAdI MD_CHANGE_MRP_DATA to easily implement a custom code that would influence an MRP element, and I even wrote a blog explaining how this BAdI could be used to make an MRP element not relevant to MRP.

In the S/4HANA world, however, this BAdI is no longer relevant. In classic MRP, this BAdI was called when MRP was reading the planning elements from the database, and this logic was pushed down into the HANA layer, in order to improve the MRP performance, and MRP Live runs completely in HANA, so an ABAP BAdI cannot be called.

Until now, the alternative was to use ABAP BAdI MD_ADD_ELEMENTS, which would work in classic MRP and MRP evaluation transaction (such as MD04) and the AMDP BAdI PPH_MRP_RUN_BADI in MRP Live (AMDP stands for ABAP Managed Database Procedures, and it is a procedure executed directly in the HANA database).

While those BAdIs were very handy, there were two downsides of implementing them in SAP S/4HANA: In most cases MRP Live plans a material in HANA, and the AMDP BAdI is called, but there are situations where MRP Live needs to plan a material in ABAP, and the AMDP BAdI won’t work. It means that both BAdIs had to be implemented, leading to additional development efforts and costs. In addition to that, the ABAP BAdI is called in the MRP evaluation transactions, such as MD04, but it is not called in the MRP Fiori Apps, which means that user would see different results depending on the transaction or app that was used.

 

New BadI PPH_SUPPLY_DEMAND_LIST

In order to resolve those problems, SAP S/4HANA 2022 introduced the new BAdI PPH_SUPPLY_DEMAND_LIST. This is an AMDP BAdI, which means that it runs directly in the HANA database, and it will work in Classic MRPMRP LiveMRP Fiori Apps and Stock/Requirements List (MD04).

This BAdI brings only one method called MODIFY_SUPPLY_DEMAND_LIST, which is called by the stored procedures that will read the planning elements from the database, which means that we can change attributes of a planning element, add new planning elements, or even make planning elements not relevant for MRP.

There are several import parameters to the BAdI method, as you can see in the following figure, which will bring useful information, like the user or the planning date. There is one changing parameter called CT_SUPPLYDEMANDITEMLIST, which will bring the list of supply and demand elements (sales orders, production orders, planned orders, purchase requisitions, etc…) that MRP read from the database for a specific material.

It is important to mention that changes in planning elements made by an implementation of this BAdI will only be considered by MRP during the planning run, and they will not be saved into the database. For example, if you use this BAdI to change a planned order date, MRP will consider the adjusted date for this planned order during the planning run, but the dates won’t be changed in table PLAF.

Also, any changes implemented by this BAdI are taken into consideration by MRP during net requirements calculation, and no consistency check is carried out after the BAdI execution. Therefore, if you adjust the quantity of a planning element using this BAdI, MRP will use this quantity during net requirements calculation, and your BAdI will have a direct influence in the MRP results, so it should be used very carefully! For example, if you use this BAdI to reduce the quantity of a sales order, MRP will not cover entirely a possible shortage that could be caused by this sales order.

 

Example implementation of BAdI PPH_SUPPLY_DEMAND_LIST

With the new BAdI PPH_SUPPLY_DEMAND_LIST, an example implementation class is delivered by SAP, with a sample code that can be used as an example for you to build your own BAdI implementation.

This sample code proposes solutions for the following scenarios:

  • Exclude a storage location from planning.
  • Exclude expired batches from planning.
  • Move the requirement date 2 days ahead for customer orders.

Excluding expired batches from MRP, also known as shelf-life planning, is a very common requirement, especially for pharma and food industries, in order to ensure that expired batches will not be considered as available for components and finished products. Standard MRP does not consider the batch expiration while planning, and companies had to choose between enhancing MRP to enable this functionality, or implement PP/DS, since it provide a standard heuristic to support shelf-life planning.

The sample code proposed by this BAdI adds planned independent requirements to reduce the quantity of batch from the available quantity, on the expiration date. This way, MRP will not consider this quantity as available and it will create a new replenishment proposal to cover a shortage.

The following figure shows the code provided in the sample implementation and, as you can see below, it is commented, so you can only use it as a model to develop your own BAdI implementation.

 

Conclusion

With a single BAdI that can be used in MRP Live, Classic MRP, Stock/Requirements List and MRP Cockpit Fiori Apps, we will be able to reduce the development efforts and the costs to enhance MRP. A single BAdI implementation will also reduce the number of errors, and ensure that the custom logic will be consistent between the different MRP transactions and apps.

The sample code delivered by SAP will also help us to fulfill the very common requirement  to exclude expired batches from MRP, and accelerate the development of enhancements.

We just need to carefully use this BAdI, making sure that the logic implemented will keep the MRP results consistent and that it will not cause shortages or build unnecessary stock for our products.

More information about this BAdI and additional MRP BAdIs can be found in the IMG Activity Business Add-Ins for Requirements Planning.

 

Brought to you by the SAP S/4HANA RIG


Source: https://blogs.sap.com/2023/08/03/sap-s-4hana-2022-new-badi-to-influence-mrp-elements-in-mrp-live-and-classic-mrp/

Nenhum comentário:

Postar um comentário