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: 

Substitute Account in ME_PROCESS_REQ_CUST (ME51N)

Missschaaa
Participant
0 Kudos

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?

Regards

Michael

11 REPLIES 11

raymond_giuseppi
Active Contributor
0 Kudos

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?

Missschaaa
Participant
0 Kudos

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.

Missschaaa
Participant
0 Kudos

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 ).
   ENDLOOP.

0 Kudos

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.

0 Kudos

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.

0 Kudos

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?

Missschaaa
Participant
0 Kudos

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

0 Kudos

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.

Missschaaa
Participant
0 Kudos

You mean like this?

   CHECK im_count EQ 1.

   ls_item = im_item->get_data( ).

   TRY.
       lo_services ?= im_item.
     CATCH cx_sy_move_cast_error.
       RETURN.
   ENDTRY.

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

*  DO Changes In LT_ACC_TAB FIELD SAKTO
   (....)

   CALL METHOD lo_services->set_data
     EXPORTING
       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?

Missschaaa
Participant
0 Kudos

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?

0 Kudos

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.