03-06-2018 1:11 PM
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
03-06-2018 2: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?
03-06-2018 4: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.
03-06-2018 5: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 ).
ENDLOOP.
03-07-2018 6:45 AM
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.
03-07-2018 9:16 AM
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.
03-07-2018 9:41 AM
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?
03-07-2018 2: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?
03-08-2018 10:44 AM
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.
03-08-2018 6:21 PM
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?
03-14-2018 8:16 AM
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?
03-16-2018 8:56 AM
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.