Skip to Content
author's profile photo Former Member
Former Member

Calculating the GR date automatically in ME21/ME22N

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Sep 23, 2013 at 04:51 AM

    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 ).

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • Posted on Sep 23, 2013 at 06:13 AM

    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 metafieldmmpur_message_forced 'E' 'ZXXXX' '123' lwa_item-lewed lv_date space space.

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.