cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement BADI for ME21N.....

Former Member
0 Kudos

Hi Experts,

I am trying to use the BAdi <b>ME_PROCESS_PO_CUST</b> for <b>ME21N</b> to extend its functionality, actually my requirement was to assign my own Purchase Order Number (<i>i am planning to assign different P.o number for different Plant</i>) whenever i create a PO....

Please help me on where and how to write the code for this requirement, i have created a implementation of the BAdi with the name <b>Z_ME_PROCESS_PO_CUST</b>, so i want to know in which method(<b>POST, CHECK,CLOSE</b> etc) of this BAdi i have to write the code for my requirement.

So all i need is to know where to assign the PO number so as i get my requirement.

Plz explain step by step as iam new to BAdi....

Thanks in Advance....

Regards

Karthik D

Accepted Solutions (1)

Accepted Solutions (1)

Manohar2u
Active Contributor
0 Kudos

Can you try with PROCESS_HEADER

Former Member
0 Kudos

Hi manohar,

I tried the following code in PROCESS_HEADER, but it doesnt seems to be working...

i overwrite the po number(ebeln) value but it only gives system generated when i save the PO. i dont know why it is happening, when i debug this it shows my value in the ebeln field but its not getting updated....

Please suggest me a better way to do this.....

Regards

Karthik D

DATA: ls_mepoheader TYPE mepoheader,

ls_mepoitem TYPE mepoitem,

lt_items TYPE purchase_order_items,

an_item LIKE LINE OF lt_items,

ls_ekko TYPE ekko,

ls_ekpo TYPE ekpo.

ls_mepoheader = im_header->get_data( ).

<b> ls_mepoheader-ebeln = '4500017333'.</b> ' Just hardcoded to see whether its working, but its not !!! - any idea

MOVE-CORRESPONDING ls_mepoheader TO ls_ekko.

break-point.

lt_items = im_header->get_items( ).

LOOP AT lt_items INTO an_item.

ls_mepoitem = an_item-item->get_data( ).

MOVE-CORRESPONDING ls_mepoitem TO ls_ekpo.

*--- Call to function module FM_CHECK_PO_PAYMENT_TERMS to

  • Check whether payment term in purchase order header

  • matches special payment term associated with the material group

  • in the line item, if it is a special material.

CALL FUNCTION 'FM_CHECK_PO_PAYMENT_TERMS'

EXPORTING

i_ekpo = ls_ekpo

CHANGING

i_ekko = ls_ekko

EXCEPTIONS

error_message = 1.

*--- Check for Fast Pay purchase orders

CALL FUNCTION 'FM_CHECK_FAST_PAY_TERM'

EXPORTING

i_ekpo = ls_ekpo

CHANGING

i_ekko = ls_ekko.

IF sy-subrc NE 0.

mmpur_message_forced sy-msgty sy-msgid sy-msgno sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

CALL METHOD im_header->invalidate( ).

ENDIF.

ENDLOOP.

IF NOT ls_ekko-zterm IS INITIAL.

ls_mepoheader-zterm = ls_ekko-zterm.

CALL METHOD im_header->set_data( ls_mepoheader ).

Answers (0)