Convert remaining quantity left by Scheduling agreement to Purchase Requisition at MRP?

One requirement for the MRP run is: When the scheduling agreement quantity runs out, prevent MRP from using the scheduling agreement to meet the new requirements, but by generating new purchase requisites instead.

Few key quantities here:

  1. Target quantity from the scheduling agreement (EKPO-KTMNG) which is the total quantity agreed with the vendor. And MRP will not consider this quantity now, which keeps increase creates new schedule line items once meet the validation period which should be prevented as it has limits of this scheduling agreement.
  2. Open quantity left for this scheduling agreement. We can check the changes in the history of this scheduling agreement (EKBE-MENGE with considering Debit/Credit Indicator SHKZG), and get the open quantity by using: Target quantity minus accumulated quantity been used. 
  3. The requirement quantity from each MRP element line. Here I’m going to use BADI: MD_CHANGE_MRP_DATA~CHANGE_MDPSX_MDBS (Change data when importing purchase order/ delivery schedule to deal with data from scheduling agreement against new required quantity. Please check this for more details about this BADI.

From my understanding, there could be 3 different scenarios for this requirement:

  • <Scenario 1> SA open quantity still available for new requirement then carry on the standard SA processing to meet the requirement;
  • <Scenario 2> SA open quantity can meet only part of the new requirement then change the quantity of MRP element line with remaining quantity of SA. Besides, create PR with missing quantity;
  • <Scenario 3> SA open quantity already run out& can’t meet any new requirements (make those SA lines invalid (make this element no relevant to MRP which should disappear from MD04 requirement list ). Besides, create PR with quantity from the new requirement).

I created the implementation of BADI MD_CHANGE_MRP_DATA~CHANGE_MDPSX_MDBS and find what I can achieve:

  • Get accumulated requirements from each MRP element by ch_mdps-mng01 ;
  • Get the open quantity of schedule agreement by EKPO-KTMNG with SUM of EKBE-MENGE;
  • Determine when SA can’t meet the requirement by comparing open quantity and new requirements per MRP element line.
  • It’s possible to change the quantity of SA of MRP lines for Scenario 2, and also make it invisible for case 3.

Now the issue is how to convert those remaining requirements left by SA to Purchase requisition. It not only changes the data of the MRP element from SA but needs to create non-existed data of the MRP element for PR which share totally different structures and processing logic.

I thought I could generate PR through MD_CHANGE_MRP_DATA~CHANGE_MDPSX_EBAN by impacting its input parameter IM_EBAN and realize that it’s too late to change data for PR cause it has already been generated if has any PR at least for this BADI. If we collect the left open requirement and generate PR separate from the MRP run, then it’ll not show in the requirement list of MD04 for sure~

I heard from the PP colleague it is achievable. So any Suggestions are welcome, thanks!