Populate the Latest GR Date based on the Delivery Date in the PO Creation(ME21N) and Change(ME22N)

By Khaja Moulali Shaik, Siemens IT Solutions and Services

Scenario:  

When creating a PO (ME21N) or changing the PO (ME22N), the ‘Latest Possible Goods Receipt Date’ should be calculated 60 days to the Delivery Date and it should populated automatically.  

Note: This functionality will work, only the user click on ‘CHECK’ or ‘SAVE’ buttons.  

Step by Step Solution:  

Step 1:  

Go to Transaction Code SE19.  

Provide the Classic BADI Name as ‘ME_PROCESS_PO_CUST’.  

And Click on ‘Create Implementation’ to implement the BADI.  

Note: Please check whether this BADI is already implemented in the system or not. If yes, use the Implemented BADI only. Because this BADI is not for multiple use.  

To check whether the BADI is for multiple use or not,

    SE18àBADI Name à Enhancement Implementation à Overview.  

 Step 2:  

 Give the implementation Name and click on ‘Continue (Enter) .  

Give the meaningful description for that implementation.  

 

For our requirement, we need to change the Latest GR Date based on the Delivery Date. This process is done in Item Level. So, we will use the method ‘PROCESS_ITEM’ in the class ‘ZCL_IM_ME_PROCESS_PO_NEW’.  

Note: This class will create automatically. Class name will be combination of First letter in Implementation name (Z), ‘_CL_IM_’, and the remaining letters in implementation name (ME_PROCESS_PO_NEW).  

Step 3:  

Double click on the method ‘PROCESS_ITEM’. And save it.

System will provide you the editor to write the code.  

STEP 4:  

Write the below code in between Method and End Method.  

  IF  sy-ucomm EQ 'MECHECKDOC' OR
      sy-ucomm 
EQ 'MESAVE'.
    
DATA : lt_items      TYPE purchase_order_items        ,
           lwa_items     
TYPE purchase_order_item         ,
           lwa_item      
TYPE mepoitem                    ,
           ls_mepoheader 
TYPE mepoheader                  ,
           lt_item       
TYPE STANDARD TABLE OF mepoitem  ,
           im_header     
TYPE REF TO if_purchase_order_mm .
    
DATA : lv_date       TYPE sy-datum.
* Geting the Header details
    im_header = im_item->get_header( ).
* Getting the Items from the Header
    lt_items  = im_header->get_items( ).
    
LOOP AT lt_items
        
INTO lwa_items .
*   Get PO item data
      lwa_item = lwa_items-item->get_data( ).
      lv_date = lwa_item-eeind + 
60 .
      
IF lwa_item-lewed IS INITIAL .
        lwa_item-lewed = lv_date .
      
ELSEIF lwa_item-lewed <> lv_date .
        
MESSAGE 'Change the GR Date!!' TYPE ’E’.
      
ENDIF.
      
CALL METHOD lwa_items-item->set_data( lwa_item ).
    
ENDLOOP .
  
ENDIF.  

Step 5:  

Activate the method and implementation also.


 Please send us your feedback/suggestions at webmaster@SAPFunctional.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPFunctional.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image