Skip to Content
avatar image
Former Member

Problem in using BADI ME_PROCESS_PO_CUST for Line Item Changes

check  sy-tcode = 'ME21N'
     or sy-tcode = 'ME21'
     or sy-tcode = 'ME22N'
     or sy-tcode = 'ME22'
     or sy-tcode = 'ME23N'
     or sy-tcode = 'ME23'.

   data : lv_bnfpo  type bnfpo.
   data: ls_mepoitem type mepoitem.
   data :ls_header type ref to if_purchase_order_mm.
   data : zbus_area type eban-zbus_area,
          zmark_unit type eban-zmark_unit,
          zerp_pro_code type eban-zerp_pro_code.

   include mm_messages_mac.

IMPORT lv_bnfpo to lv_bnfpo FROM MEMORY ID 'ZHDR'.

   ls_mepoitem = im_item->get_data( ).

if lv_bnfpo <> ls_mepoitem-ebelp.

   if not ls_mepoitem-banfn is initial.

     select single zbus_area zmark_unit zerp_pro_code
       into (zbus_area,zmark_unit,zerp_pro_code)
          from eban where banfn = ls_mepoitem-banfn
                                 and bnfpo = ls_mepoitem-bnfpo.

     if sy-subrc = 0.

       ls_mepoitem-zbus_area  = zbus_area.
       ls_mepoitem-zmark_unit = zmark_unit.
       ls_mepoitem-zerp_pro_code = zerp_pro_code.

       call method im_item->set_data
           im_data = ls_mepoitem.

   ls_mepoitem = im_item->get_data( ).

lv_bnfpo = ls_mepoitem-ebelp.
EXPORT lv_bnfpo FROM lv_bnfpo TO MEMORY ID 'ZHDR'.


I have created three Custom fields in PR and PO at line item level. I want to import the same values given for custom fields in PR to custom fields in PO. I am using BADI 'ME_PROCESS_PO_CUST' to update the custom fields automatically. In the BADI, Method 'PROCESS_ITEM' was used. In the Methods, I am using both methods 'GET_DATA' and 'SET_DATA' to update the fields.

When PR has two or more line items, only the values of the last line item in PO are getting updated. The other line items' values are not updated or updated with the last line items' values.

I have attached the program lines for reference.

Kindly provide me a solution,

Thanks & Regards,


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers