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.
Give the name for the implementation.
Check for the method PROCESS_HEADER.
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_mepho-lifnr.
lw_mepho-ekgrp = 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 |