Skip to Content

Substitute Account in ME_PROCESS_REQ_CUST (ME51N)

Mar 06 at 01:11 PM


avatar image

Hello guys,

I want to use BADI ME_PROCESS_REQ_CUST to substitute the account in purchase requisition. Therefor I wanted to use method PROCESS_ACCOUNT but unfortunately it is not getting triggered. I found out that with positiontype 'D' this method does not get triggered. So how else can I substitute the account in position data? I can see that method PROCESS_ITEM is getting triggered, but as far as I can see I canot access accounting data in this method?



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Raymond Giuseppi
Mar 06 at 02:47 PM

The parameter received in PROCESS_ITEM carries the IF_ACCT_CONTAINER_MM interface, did you check its methods like GET_ITEMS, REMOVE and CREATE_ITEM?

10 |10000 characters needed characters left characters exceeded
Michael Boguth Mar 06 at 04:53 PM

Can you give me some help for using them? It is like calling a reference with a reference of a reference. Too much OO for my mind. It looks like that I can use the GET_ITEMS and CREATE_ITEM line but I would be glad to have some help to deal with it.

10 |10000 characters needed characters left characters exceeded
Michael Boguth Mar 06 at 05:08 PM

Is it correct like this? Do not know if this code looks right, because too much OO for me. At least it does not get a dump ;-)

But unfortunately nothing gets updated.

   DATA: ls_exkn      TYPE exkn,
         ls_mereqitem TYPE mereq_item,
         lr_acc_list  TYPE mmpur_accounting_list,
         lr_acc_type  TYPE mmpur_accounting_type.

   ls_mereqitem = im_item->get_data( ).

   lr_acc_list = im_item->if_acct_container_mm~get_items( ).

   LOOP AT lr_acc_list INTO lr_acc_type.
     ls_exkn = lr_acc_type-model->get_exkn( ).

*    Change SAKTO
     (.....) coding for change

     lr_acc_type-model->set_exkn( ls_exkn ).
Show 3 Share
10 |10000 characters needed characters left characters exceeded

Code is correct, but it's not always allowed to bypass material valuation Customizing (you can check this one with a break-point at start of FM MR_ACCOUNT_ASSIGNMENT) as the non-activation of process_account method would indicate. Did you also try to use get/set_exknx.


What can I see in this FM? When I debug it does not find an entry in table T030 and after rc 4 it leaves the FM. I think this is correct because when finding one it would overwrite it?

After putting my answer here yesterday, I found the set/get_exknx methods as well and tried working with them. Unfortunately nothing changed, still value does not get updated.


Another point of view. Can it depend on the field itself?

When I want to change SAKTO in foreground I am not able to do this in account assignment tab.

I have to do this services tab. With F1 Help on the field, it is a structure called ESKN, not EXKN. Maybe updating the wrong field?

Michael Boguth Mar 07 at 02:32 PM

I now tried with different itemcategory (blank, 'K'). Everything works fine with it, even PROCESS_ACCOUNT gets triggered then. But as far as I switch it to itemcategory 'D' (service), neither the method gets triggered nor the value changes in method PROCESS_ITEM.

Any ideas whats so special about this itemcategory?


unbenannt.png (38.3 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Then, for service only, Look for my answer to ME_PROCESS_REQ_CUST~PROCESS_ITEM Activity Number (ESLL-SRVPOS) for how-to access service data, and modify with methods like GET and SET_DATA.

Michael Boguth Mar 08 at 06:21 PM

You mean like this?

   CHECK im_count EQ 1.

   ls_item = im_item->get_data( ).

       lo_services ?= im_item.
     CATCH cx_sy_move_cast_error.

   CALL METHOD lo_services->get_data
       im_limit     = lf_limit
       ex_comsrv    = ls_comsrv
       ex_acc_tab   = lt_acc_tab
       failure      = 1
       illegal_data = 2
       OTHERS       = 3.


   CALL METHOD lo_services->set_data
       im_comsrv  = ls_comsrv
       im_acc_tab = lt_acc_tab.

It looks good and changes the SAKTO valie. Thanks a lot for that, brilliant! But is it normal that field gets only updated in account assignment tab first, but not in service tab? Only after saving it it gets updated in both.

Adding the methods lead to an endless loop. I bypassed it with checking the im_count parameter, but why is this method called endless times now? I only got one service position row. So is the coding right like this?

10 |10000 characters needed characters left characters exceeded
Michael Boguth 6 days ago

Is it possible that this BADI is only triggered in foreground or when using BAPI_PR_CREATE? When creating BANFs with BAPI_REQUISITION_CREATE, it looks like that it not gets triggered. It looks like that I have to use user-exit EXIT_SAPLMEWQ_001 for that?

Show 1 Share
10 |10000 characters needed characters left characters exceeded

This is an obsolete BAPI (*) related to ME51 and not to Enjoy transaction ME51n, always use BAPI_PR_CREATE "Create Enjoy Purchase Requisition" instead.

(*) Ref. 1803189 - FAQ: End of Support of ME21, ME51, and BAPI_PO_CREATE etc.