Skip to Content
0
Feb 17, 2015 at 11:44 AM

Modify COBL-GSBER in ME21N Account Assignment

400 Views

Hi experts,

I need to modify field GSBER from tab accountings in ME21N.

I've tried implementing badi ME_PROCESS_PO_CUST, then I tried with both methods PROCESS_ACCOUNT and PROCESS_ITEM.

PROCESS_ACCOUNT is executed but then GSBER has the same value.

After this method, PROCESS_ITEM is executed but I get this message:

Change Business Area could not be effected

The business area (GSBER) is filled whenever I inform sales order in tab Account Assignment, but this value is already informed when the debugs reaches method PROCESS_ITEM.

My code is as follows in PROCESS_ITEM:

METHOD if_ex_me_process_po_cust~process_item.

DATA: lw_item TYPE mepoitem,
lw_gsber TYPE gsber.

DATA: itab_acct TYPE purchase_order_accountings,
acct_interface TYPE purchase_order_accounting,
lw_acct TYPE mepoaccounting.

* Get Item Info
CALL METHOD im_item->get_data
RECEIVING
re_data = lw_item.

REFRESH itab_acct.
CALL METHOD im_item->get_accountings
RECEIVING
re_accountings = itab_acct.

LOOP AT itab_acct INTO acct_interface.
CLEAR lw_acct.
* Get the newly updated PO item data
CALL METHOD acct_interface-accounting->get_data
RECEIVING
re_data = lw_acct.

IF lw_item-knttp = 'M' AND lw_acct-vbeln IS NOT INITIAL
AND lw_acct-vbelp IS NOT INITIAL.
SELECT SINGLE gsber
INTO lw_gsber
FROM vbap
WHERE vbeln = lw_acct-vbeln
AND posnr = lw_acct-vbelp.
IF sy-subrc IS INITIAL AND lw_gsber IS NOT INITIAL.
lw_acct-gsber = lw_gsber.
CALL METHOD acct_interface-accounting->set_data
EXPORTING
im_data = lw_acct.
ENDIF.
ENDIF.
ENDLOOP.

ENDMETHOD.


Maybe I am triing to do something that is impossible ??

How is this field filled ?


Thanks in advance,


María