Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Modify COBL-GSBER in ME21N Account Assignment

maria_merino
Active Participant
0 Kudos

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

10 REPLIES 10

atul_mohanty
Active Contributor
0 Kudos

Hi

Please check with your functional consultant if it is derived from the WBS element.

0 Kudos

Hi Atul,

Yes, the consultant has confirmed that it ir derived from WBS element.

María

VenkatRamesh_V
Active Contributor
0 Kudos

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.

0 Kudos

Thanks for yoour answer Venkat, but I get an error whenever I run ME21N with this code..

0 Kudos

Can you tell me the error.

Regards,

venkat.

0 Kudos

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.

0 Kudos

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.

0 Kudos

Hi Venka,

Now I don't have the error but I get the same message I was getting before: ME 664

María

0 Kudos

Hi,

Can you explain in brief.

Regards,

Venkat.

0 Kudos

The error says: Change business area could not be effected