Skip to Content

Requirement:

With respect to a production order AUTOMATE the distribution of quantity (basically split production order quantity) and assign batch numbers from an existing ztable to each line split while doing a Goods Receipt with reference to a production order.

Prerequisite:

  1. Make sure that the automatic batch creation setting in Production Scheduling profile has been turned-off so that the Production order batches are created only through the enhancement framework. (this is customizing setting and is to be made by Functional consultant)
  2. Implement enhancement from document ‘Creating Multiple batches for a Production order’ there by creating multiple batches for a production order (Optional if you do not wish to have multiple batches and only want to distribute quantity automatically where in u just have to implement the enhancement to split the quantity based on some criteria)
  3. Production order batches are available in a ztable. Here i am using database table ‘ZPROD_BATCHES’ with below fields.(Optional if you do not wish to have multiple batches and only want to distribute quantity automatically where in u just have to implement the enhancement to split the quantity based on some criteria)

          Capture2.PNG

Issue:

The standard functionality in SAP is to manually distribute the quantity by clicking on the button distribute quantity. There is no automation by default, so an enhancment in the standard functionality is needed to meet the requirement.

Below screenshots shows the manual process of distributing the quantity, and the solution part of this document explains the enhancement to achieve automation of quantity distribution.

Go to T-code MIGO  -> Select operation GOODS RECEIPT -> Select reference document as ORDER -> then Production order number, it will display the details related to the production order

Capture2.PNG

After you click on the Distribute Qty button a new window will popup asking for manual distribution of quantity where you have to enter the quantity and other information for each single line based on the number of lines you want to distribute the production order quantity. the screen shot below shows the same by distributing the production order quantity into 2 lines.

Capture2.PNG

once u have done distributing the quantity and batch assignment, clicking on ‘ADOPT’ button will adopt the changes in the goods receipt and the quantity will be distributed accordingly as below.

Capture2.PNG

Solution :  

Although there can be many possible solutions to this but the the one that worked out for me is documented here. This solution in specific deals with the process of automation of quantity distribution along with the newly created batch number assignment (to the distributed quantity) from a ztable while doing Goods Receipt in MIGO with reference to a production order, but in general can also be used to distribute the quantity automatically and eliminate the manual steps.

Note:

Enhancement Section, Spots and their respective implementation knowledge is necessary for this. Information like what is it and how to implement it can be found online. For those who have no knowlegde on the new enhancment framework, i suggest you go through the documentation available online and familiarize yourself with the features and process related to it. 

The default logic with respect to the manual process of distribute quantity button is written in an enhancement-section ‘POPUP_CALL_03’ of include ‘LMIGOSP3’, see below screenshot for reference. This logic handles default SAP process.

Capture2.PNG

To automate the quantity distribution we have to enhance the current logic, so create an implementation for the enhancement-section ‘POPUP_CALL_03’.

one important thing to note with the enhancement-section is that when you try to implement a new logic for it, you are actually replacing the existing default logic (it was having earlier) with a new logic. so the existing logic is deactivated and the new implementation you just created will hold the logic from the deactivated code (which is proposed in the new implementation by default). Now it is up to you to decide whether to keep the proposed code along with your new code or to remove the proposed code and only add your new code. It may not be clear at this point of time but once you start creating an implementation for the enhancement-section you will understand what i am trying to say.

So create an implementation for the enhancement-section ‘POPUP_CALL_03’, following which the system proposes the default code.

In this scenario we need the proposed code so we add the proposed code to the else part of an IF-ELSE condition as below.

Capture2.PNG

With the proposed code in the else part you can write your new logic in the if part where the if condition holds your criteria for executing the logic. This enhancement is generic to most of the operations in MIGO so make sure to add in checks for the type of MIGO operation (Goods receipt / Goods issue etc) and reference document type (Order / Purchase order etc) . Also this enhancement will have global effect so do not forget to add checks on the specific palnt or any other criteria, whichever is suitable based on the requirement.

So in this scenario ideally the IF condition should hold the following checks.

IF  GODYNPRO-ACTION = ‘A01’ (Goods receipt) AND GODYNPRO-REFDOC = ‘R08’ (Order) AND GOITEM-WERKS = ‘XYZ’.

(GODYNPRO and GOITEM are structures available at this point in the program and hold relevant information of the process.)

Adding the above checks will ensure that the enhancment will not be executed for other MIGO operations and other reference document type. for others the else part comes in to picture which holds the default (proposed) code from SAP.

In this scenario the quantity has to be distributed based on the number of records available for the production order in table ZPROD_BATCHES, Only part left out is to fetch the relevant production order data into an internal table from the table ZPROD_BATCHES, and then for every relevant production order record in the table ZPROD_BATCHES, fill the internal table ‘PT_GOSPLIT’ with the distributed quantity and append the records. The code below gives you an exact picture of what i am trying to say.

************ Start of implementation ************

   DATA : ta_gosplit TYPE STANDARD TABLE OF gosplit,
                wa_gosplit TYPE gosplit.

   DATA : ta_pobatch TYPE STANDARD TABLE OF zprod_batches,
                wa_pobatch TYPE zprod_batches.

IF  GODYNPRO-ACTION = ‘A01’ AND GODYNPRO-REFDOC = ‘R08’ AND GOITEM-WERKS = ‘XYZ’. “XYZ= plant name

   SELECT * FROM zprod_batches INTO TABLE ta_pobatch WHERE aufnr = goitempps_aufnr. “goitempps_aufnr = production order number

      LOOP AT ta_pobatch INTO wa_pobatch.
           wa_gosplitlgort = goitemlgort.
           wa_gosplitcharg = wa_pobatchcharg.
           wa_gosplitbwart = goitembwart.
           wa_gospliterfmg = wa_pobatchbdmng.
           wa_gospliterfme = wa_pobatchmeins.
           wa_gosplitlgobe = goitemlgobe.
           wa_gosplitsplit_line = sytabix.
           APPEND wa_gosplit TO ta_gosplit.
           CLEAR wa_pobatch.
    ENDLOOP.
    IF NOT ta_gosplit IS INITIAL.
      pt_gosplit = ta_gosplit.
      REFRESH : ta_pobatch, ta_gosplit.
    ENDIF.

ELSE.

* Below is the existing functionality from the enhancemnt section POPUP_CALL_03  in the else part (proposed code) as illustrated earlier in this document.

Capture2.PNG

ENDIF.

************End of implementation*****************

After activating the enhancement implementation, for MIGO operation with GOODS RECEIPT and reference order ORDER of plant ‘XYZ’ will have the automated distribution of quantity based on the ztable ZPROD_BATCHES. The rest of all the MIGO operations will hold Standard SAP functionality.

The enhanced feature of the MIGO transaction is demonstrated below.

Go to T-code MIGO  -> Select operation GOODS RECEIPT -> Select reference document as ORDER -> then Production order number of palnt XYZ, it will display the details related to the production order

Capture2.PNG

Click on the Distribute Qty button. earlier it used to display a popup window to manually distribute the quantity. But after the new enhancement popup window is supressed and the quantity is distributed automatically based on the data from the ztable.

Capture2.PNG

Here the automation aspect is to avoid manual search for the production order batches and the line split quantity by implementing the enhancement to fetch the relevant data from the concerned ztable and populate it by default for production orders from plant XYZ.

*****************************************************THE END********************************************************

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Kiran Kerudi

    Hi Umar,

    I did follow the same steps. But I couldnt trigger the code.

    The enhancement is active though. Can you please help me on that ?

    Thanks.

    (0) 
    1. Manjunath Mn

      Hi Kiran,

      Check this enhancement (/SAPMP/FDE_CGM_SAPLMIGO ) switch position. This enhancement will be above your Z* enhancement.

      If the switch position is “ON” then your enhancement will not trigger.

      (0) 

Leave a Reply