Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating the GR date automatically in ME21/ME22N

Former Member
0 Kudos

Hi  Gurus,

I have a requirement of calculating the GR date automatically and updating it when ME21N/ME22N is triggered.

I am using the code below in the BADI ME_PROCESS_PO_CUST~PROCESS_ITEM.

Validation for document types is done.
* 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( ).

The value 60 is fetched from a custom table.


      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. 

For a change in delivery date i have to compare the calculated GR date value with the GR date that was available initially.

Can you please suggest if there are any structures to get the value of the GR date that was stored initially in Ekpo table.

The tables TEKPO BEKPO etc are not getting populated in this BADI.

Thanks,
Prema

1 ACCEPTED SOLUTION

Sijin_Chandran
Active Contributor
0 Kudos

Hello Prema ,

For this purpose better use Customer Exit MM06E005.

There are two internal tables available for EKPO , YEKPO ( Containing old values ) and XEKPO ( Containing new values ).

4 REPLIES 4

Sijin_Chandran
Active Contributor
0 Kudos

Hello Prema ,

For this purpose better use Customer Exit MM06E005.

There are two internal tables available for EKPO , YEKPO ( Containing old values ) and XEKPO ( Containing new values ).

0 Kudos

Hello,

Thank you for the reply..

I have sorted it out by creating an internal table for EKPO where data is already available..

I have another issue of ME21N-Save is not getting triggered where as me22n N 23N is working fine..

Can you help??

Regards,

Prema

raymond_giuseppi
Active Contributor
0 Kudos

There are methods similar to get_data in this BAdI :

  • GET_PREVIOUS_DATA "Get Item Data Prior to Validation"
  • GET_PERSISTENT_DATA "Get Posted Item Data" (database)

So the answer is GET_PERSISTENT_DATA

But you are writing your code in IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM, and there you  process every item each time an item is changed . Why not use IF_EX_ME_PROCESS_PO_CUST~OPEN for already existing items, and then only update the current item in IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM ?

Also don't use a wild (or old-fashioned) MESSAGE statement, but use the available macros as described in BAdI documentation :

mmpur_metafield mmmfd_latest_gr. " Look at TYPE-POOLS MMMFD for a list of metafield

mmpur_message_forced 'E' 'ZXXXX' '123' lwa_item-lewed lv_date space space.

Regards,

Raymond

0 Kudos

Hello,

Thank you for the reply..

I have sorted it out by creating an internal table for EKPO where data is already available..

I have another issue of ME21N-Save is not getting triggered where as me22n N 23N is working fine..

Can you help??

Regards,

Prema