Making an element not relevant to MRP or MD04 using BAdI MD_CHANGE_MRP_DATA
In some business scenarios, you need to control if an specific planning element will be relevant to MRP or not. For some MRP elements, there is no customizing or master data setting to control that, therefore, SAP delivered BAdI MD_CHANGE_MRP DATA, which allows you to add a custom logic to define the MRP availability of each planning element.
This BAdI is called during the MRP run and on the MRP transactions, such as the stock/requirements list.
On the screenshot below you can see that there is an element PRqRel. This element is MRP relevant, as it is turning the available quantity negative and a purchase requisition was created by MRP to cover it.
It is a very commomn business requirement to have only stock transfer order (not requisition) releases relevant to MRP on the supplying plant. On this document you will find an example of how this BAdI can be used to make a stock transfer requisition release not relevant to MRP on the supplying plant.
Firstly, open BAdI MD_CHANGE_MRP_DATA on transaction SE18. Clicking the button “documentation” you will find a detailed description of this BAdI.
On tab “interface” you will find a list of all the available methods. There is one method for type of each planning and, since this example is focused on stock transfer requisitions releases, we will use method CHANGE_MDPSX_MDUA.
Go to the menu GOTO, SAMPLE CODE and choose the option DISPLAY.
Here, double click the method CHANGE_MDPSX_MDUA.
Here you will find a sample code delivered by SAP that makes stock transfer requisitions releases not relevant to MRP (this logic replaces the old modification note 190298). This code will be used as a base for our BAdI implementation.
Get back to transaction SE18 intial screen, choose the menu IMPLEMENTATION and CREATE and choose a name for your BAdI,
On the next screen, write a short text and double click method CHANGE_MDPSX_MDUA, on tab interface. You may be prompted to save and choose a package to your BAdI. You may click the button “LOCAL OBJECT” if you don’t have a package.
Now copy the sample code, make the desired changes and activate your method.
Go back to the previous screen and activate the BAdI. If the BAdI is correctly activated, you will see the text “Implementation is called” on field “Runtime Behavior”.
Checking the same material from the first screenshot again after the MRP run, we can notice that the purchase requisition was deleted and that stock transfer requisition release does not affect the available quantity anymore.
The same logic can be used on another methods to control the MRP relevance of other planning elements. Basically, field VRFKZ from the internal table CH_MDPS controls the MRP relevance of an MRP element. Besides that, another fields of CH_MDPS can be changed and on the documentation you can find a list of the available parameters. If you don’t want to see the planning element on MD04 you should use the parameter CH_EXIT.
You should consider that this BAdI will be called during the MRP run and a complex logic implemented here may affect the MRP overall performance. Also, changes made on planning elements within this BAdI are not saved on the database, however, they will be considered by MRP, therefore, this BAdI should be used very carefully.
For more details about all the BAdIs available on MRP, see the following document:
If you are facing any problem with a BAdI on MRP, see the following note:
2012620 | MRP: Problems with BAdIs |
Very usefull article!! Thanks Caetano..
Very helpful, Caetano!
Really Good one ! What kind of scenario we can use it ?
Hello
This BAdI can be used on many different scenarios, where you want to make an element (sales orders, reservations, etc...) not relevant to MRP.
This is specific implementation was suggested as the solution on a thread on the MM space last week, where the user would like to have only stock transfer order releases (not requisitions) relevant to MRP.
BR
Caetano
Hi Caetano,
I have arequirement as below.
Plant A receving plant
Plant B issusing Plant
Order qty is 100
When there is shortge of item XXX in Plant A after running the MRP system should create a STO PR to plant B.Once the PR is created through MRP in Plant A its converted to STO .
Now if Plant B doesnt have stock , Run MRP in plant B its creates a normal PR which gets converted to PO and the stock is received from the vendor.
The PR created in Plant B is picking the qty as per the material master (MRP views) setting in Plant B.
I want to know what setting should be done so that MRP in plant B should consider the demand qty from Plant A i.e 100 nos.And PR created in plant B should have linkage wrt to PR Qty from plant A
Thanks in advance for your replies
Regards
Sudheer
Caetano,
Thanks a lot for sharing ur Exceptional Knowledge. Kudos to ur efforts. 🙂
Caetano,
Can MD_CHANGE_MRP_DATA be used to include expiring material out in the future? I looked through the Method options in Interface section but did not see anything for expiry.
Please advise if this is possible or if you know another way to include expiry in MD04.
Thank you,
Lloyd
Hello Lloyd
This BAdI can only be used to change existing MRP elements, not to include a new one.
However, you can use BAdI MD_ADD_ELEMENTS to include a new element on MRP.
I wrote the following document with the most useful BAdIs on MRP, which may be used for further reference:
BAdIs for MRP
Regards
Caetano
Hello Caetano,
We have implemented MD_ADD_ELEMENTS in S4 1610 On-premise version and it worked well.
However, we are upgrading to 1909 and I noticed that the BADI MD_ADD_ELEMENTS is not triggering.
Could you please advise if we need to perform any additional steps to make it work.
Thanks,
Naga
HI Naga,
Were you able to solve this issue? We currently have the same problem.
Thanks!
Hello Wolfgang Ostyn,
Yeah, we were able to solve it.
Please create an enhancement from SE19 for the BADI: MD_ADD_ELEMENTS and make sure following are checked:
Hi Caetano,
We are using SAP 4.6 System and mentioned Badi is not implemented still PRqRel is not creating Planned Orders.Can you suggest Please.
Thanks
Amulya
Very useful. Thanks
Just what I was looking for Caetano, thank you!
Hello Caetano,
Thanks for a detailed Example on this BAdi. We have a kind of Requirement where we do not want MRP to consider the stock that is less than 1 (In Fraction). For E.g 0.3 M or 0.7M and only consider the stock which is Greater than 1.
As Advised by R.Brahmankar, We will use this BAdi and the CHANGE_MDPSX_MARD to exclude the Stock of the Materials which is less than 1 and keep you updated on the result.
Thank you.
Regards,
Kris.S
Hello
Indeed, method CHANGE_MDPSX_MARD can be used to manipulate the stock available for MRP. I think that it's just the case of reading the batch stocks from table MCHB and subtract the quantity of batches smaller than one.
If I can give you one advice is to take care with your logic and avoid selecting too much data, as it may lead to performance issues.
BR
Caetano
Hello Caetano,
Thanks for this valuable document and the very clear explication.
I have one question regarding this BADI, it is possible to influence MRP result after an MRP run ? For example, add the time spot to a schedule line or simply increase the procurement proposal quantity ?
Thank you.
Hello Mohamed
No, this BAdI is only called when reading the planning elements and the changes made will not be saved on database.
Regards,
Caetano
Hello Caetano,
Please do you have any good idea or solution logic about changing procurement proposales data by the MRP ? We are working with scheduling agreement and we need to maintain delivery time spot according to a specific logic ?
I performed a lot of research and test but no way to achieve this except using a program that is triggered after the MRP run.
Best regards,
MYZ
Hello
Check this blog:
https://blogs.sap.com/2013/08/12/badis-for-mrp
Best regards,
Caetano
Hello,
Unfortunately, there is no way to update delivery time-spot through MRP for schedule lines.
Regards,
MYZ
Hello Caetano,
Very useful this article!!!
I was analyzing the BADI MD_CHANGE_MRP DATA, because I have a problem when I send a item for a customer consignment...
I want that the MRP consider the quantity in customer consignment and don't generate a new planned order. Is possible to do this with this BADI ?
Do you know what method can I use?
Thanks!
Hello
If you want to manipulate the stock quantity there is method CHANGE_MDPSX_MARD.
Regards,
Caetano
Hello Caetano,
is it possible, by using this BADI, to make the receipt of a production order type not relevant for the MRP running but at the same time to take in account requirements for the components?
We have a special process for the approval of some production tools; so for the special order type OMST we shouldn't take in account the receipts (all produced finished items will be scrapped) but we need the explosion of the dependent requirements for the semifinished product and for the raw material inserted in the production order BOM.
Thanks in advance
Antonio
Hi Caetano,
Very useful, thank you!!
one question : is there a standard way in MD04 to use a filter on demand in order to hide non MRP relevant elements?
best regards
Hello
Yes, you can use a filter to hide the demand in MD04, but then it is only a display feature, which is not relevant during the MRP execution.
Regards,
Caetano
Hello,
We are using S/4 Hana 1610 but because of problems with scheduling agreements we are still using the classic MRP. Unfortunately for some reason the BADI MD_CHANGE_MRP_DATA is not called during classic MRP with transaction MD03.
Do you know if we can still using BADI MD_CHANGE_MRP_DATA in S/4 Hana for MRP classic ?
Thanks in advance,
Kalo
No, it cannot be used in S/4HANA due to the performance optimizations for classic MRP. You should replace it with BAdI MD_ADD_ELEMENTS.
Hi ,
We use BAdI to exclude some specific sales and purchase documents. It work well with the purchase document, but I have a problem for the sales document. There is no document number for sales document of import data CH_COPY_MDPSX ?
We used BAdI MD_ADD_ELEMENTS
Hello,
Very useful, Thank you
We implemented the BADI MD_CHANGE_MRP_DATA to exclude a MRP element. But it will not work, if we run the MRP in " parallel processing": It is not working in both MD01 and WC27 t codes.
Is there any additional thinks to be done?
Hello Baskar
This BAdI should work with parallel processing active. However, MRP will not stop in your break-points, since it is executed in the update process, in a different server.
Regards,
Caetano
Hello Almeida,
Thanks for the feedback,
It is working fine as expected
This badi is not effective because it can only exclude the elements not involved in available check