02-17-2015 11:44 AM
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
02-17-2015 1:33 PM
Hi
Please check with your functional consultant if it is derived from the WBS element.
02-18-2015 9:14 AM
Hi Atul,
Yes, the consultant has confirmed that it ir derived from WBS element.
María
02-17-2015 4:05 PM
Hi Maria,
After Endloop try with the below code and check.
Data cl_po TYPE REF TO cl_po_header_handle_mm.
cl_po ?= im_header.
IF NOT cl_po->my_recheck_queue IS INITIAL.
CLEAR cl_po->my_recheck_queue.
ENDIF.
Hope it helpful,
Regards,
Venkat.
02-17-2015 4:13 PM
Thanks for yoour answer Venkat, but I get an error whenever I run ME21N with this code..
02-17-2015 4:19 PM
02-17-2015 4:28 PM
You attempted to use a 'NULL' object reference (points to 'nothing')
access a component (variable: " ").
An object reference must point to an object (an instance of a class)
before it can be used to access components.
Either the reference was never set or it was set to 'NULL' using the
CLEAR statement.
02-17-2015 4:33 PM
Hi,
Try,
Data: cl_po TYPE REF TO cl_po_header_handle_mm,
im_header TYPE REF TO if_purchase_order_mm.
im_header = im_item->get_header( ).
cl_po ?= im_header.
IF NOT cl_po->my_recheck_queue IS INITIAL.
CLEAR cl_po->my_recheck_queue.
ENDIF.
Hope it helpful,
Regards,
Venkat.
02-18-2015 8:12 AM
Hi Venka,
Now I don't have the error but I get the same message I was getting before: ME 664
María
02-18-2015 8:27 AM
02-18-2015 9:15 AM