Introduction

In transaction ME21n, if a vendor is entered, we have to manually fill the purchasing group. It is more time consuming. So a BADI is implemented which retrieve the purchasing group of the vendor from the table LFM1 (Vendor master record purchasing organization data) and sets it to the field ‘Purchasing Group’ in the screen.

Process

The BADI used is ME_PROCESS_PO_CUST. Both vendor number (LIFNR) and purchasing group (EKGRP) is in the table LFM1.

Detailed Process

Go to the transaction SE19. Enter the BADI and click in Create Implementation.

/wp-content/uploads/2015/09/image001_792938.png

Give the name for the implementation.

/wp-content/uploads/2015/09/image003_792939.png

/wp-content/uploads/2015/09/image005_792940.png

Check for the method PROCESS_HEADER.


/wp-content/uploads/2015/09/image007_792941.png


Double Click on the method PROCESS_HEADER. Assign a package and transport request.

The method PROCESS_HEADER has only 1 parameter, IM_HEADER, which is an object reference to the interface IF_PURCHASE_ORDER_MM. Inside the interface, there are several methods. Among that methods, GET_DATA is used to retrieve the data and SET_DATA is used to write the data back.

So the above interface methods should be called from the method PROCESS_HEADER.

Source Code – PROCESS_HEADER

DATA: lw_mepho TYPE mepoheader,
lv_ekgrp
TYPE ekgrp.

CLEAR lw_mepho.

CALL METHOD im_header->get_data
RECEIVING
re_data
= lw_mepho.

SELECT SINGLE ekgrp
FROM lfm1
INTO lv_ekgrp
WHERE lifnr EQ lw_mepholifnr.

lw_mephoekgrp = lv_ekgrp.

CALL METHOD im_header->set_data
EXPORTING
im_data
= lw_mepho.

Note

The parameter for the interface method GET_DATA is a structure of type MEPHOHEADER. So, a workarea of the same type is declared. The method GET_DATA is called which returns the data which is saved in lw_mepho. The vendor number entered is in the field LIFNR in the structure lw_mepho. So the purchasing group (EKGRP) is retrieved from the table LFM1 and stored to the variable lv_ekgrp. The structure lw_mepho is updated with the purchasing group and is written back using the method SET_DATA.

Go back and activate the BADI Implementation.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply