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: 

BADI in ME21N to change cost center (EKKN-KOSTL) and also show in the screen

jgaia
Explorer
0 Kudos

Hi All

Please, I need some help.

There is a requirement to update the cost center (field KOSTL table EKKN) - when Account Assignment Category equal 'F'.

And also the cost center should appear at ME21N/ME22N/ME23N screen. The functional analyst already customized KOSTL at the screen.

I am using BADI ME_PROCESS_PO_CUST, method PROCESS_ITEM


data: ls_mepoitem type mepoitem.

data: lt_account type purchase_order_accountings.

data: wa_items type purchase_order_accounting.

data : lt_exkn type mepoaccounting.

ls_mepoitem = im_item->get_data( ).

lt_account    = im_item->get_accountings( ).

loop at lt_account into wa_items.

lt_exkn = wa_items-accounting->get_data( ).

* obtain cost center from COAS

data: l_kostv type coas-kostv.

clear l_kostv.

select single kostv

          into    l_kostv

          from   coas

          where aufnr = lt_exkn-aufnr.

if sy-subrc ne 0.

   clear l_kostv.

endif.

ls_mepoitem-kostl = l_kostv.

im_item->set_data( ls_mepoitem ).

endloop.

The problem is that EKKN-KOSTL is not been update and also the cost center at the ME21N is not displaying the cost center data.

Could you please advise?

Thanks in advance.

Joao Gaia

2 REPLIES 2

Former Member
0 Kudos

Hi Joao,

Hope the method  "PROCESS_ACCOUNT" will help to update the data in the respective fields :

The Below Documentation for Business Add-In ME_PROCESS_PO_CUST explains that the Account Data can be changes using this method .

Processing of Account Assignment Data

Functionality



The PROCESS_ACCOUNT method enables you to change the account assignment data and check it for correctness.

Parameters


The following parameters are available:

  • IM_ACCOUNT - Account assignment
    The interface reference is of the type IF_PURCHASE_ORDER_ACCOUNT_MM. You can use all methods defined there.

One more check whether the Data is maintained for the Internal Order in KO03(Display of Internal Order).

Thanks,

Seshadri

atul_mohanty
Active Contributor
0 Kudos

Hi

For the interface IF_PURCHASE_ORDER_ACCOUNT_MM there is a method SET_DATA , Did you try it ?