2023 Nov 06 7:27 AM
Hi, Gurus, hope you are doing good.
I have a requirement where in ME51N first we have to enter material number , plant and quantity and press enter.
Then in the valuation tab we have to get default value for valuation type present in Material DATA tab as INDIAN and funds center present
in Account Assignment tab as P02205.
How can I achieve both the requirements of valuation type and Funds Center with some default values based on matnr of some custom table (z table) containing both valuation class and fund center? Can someone help me with the badi or customer exit ?
2023 Nov 06 10:00 AM
Did you try with methods of BAdI ME_PROCESS_REQ_CUST such as PROCESS_ACCOUNT ?
2023 Nov 06 10:25 AM
Right now I am checking with FM EXIT_SAPLEBND_001 customer exit. I can see it is having both import and
export parameters. So I believe that it would get default values on screen. Correct me if I am wrong. Waiting for functional
consultant to fix some issues so that I can try with this FM and check if it gets triggered or not during cycle of me51n.
Correct me if I am wrong. Thanks.
2023 Nov 06 10:38 AM
If you're not comfortable with BAdIs try this customer-exit, but I can't help you as I hardly use exits when BAdIs are available.
2023 Nov 06 12:47 PM
Okay . I will try with this badi then. I have checked this badi but there are no exporting parameters for the method PROCESS_ACCOUNT. As far as my understanding, to display the processed values (default values) on the screen of transaction ME51N or any, export parameters or changing parameters should be there.
correct me if I am wrong.
Thanks.
Is it that we can use setdata and getdata which serves the same purpose of displaying on the screen. ?
2023 Nov 06 1:09 PM
Method parameters accept methods such as GET_DATA[X] and SET_DATA[X]. There are also methods for accessing item from accounting and vice versa (see links provided above).
Sample for PROCESS_ITEM
* pattern
DATA: item_data TYPE MEREQ_ITEM,
item_datax TYPE MEREQ_ITEMX,
acc_list TYPE MMPUR_ACCOUNTING_LIST.
* Current values
item_data = im_item->get_data( ).
item_datax = im_item->get_datax( ).
* Change valuation type
if item_data-BWTAR is initial.
item_data-BWTAR = <some value>.
im_item->set_data( item_data ).
item_datax-BWTAR = abap_true.
im_item->set_datax( item_datax ) .
endif.
* Get account record(s) for item
acc_list = im_item->if_acct_countainer_mm~get_items( ).
" loop, get_data set_data, etc.
2023 Nov 07 4:10 AM
Hi , Raymond,
I was trying to implement the badi and I could see that this badi is already implemented. So I have added few lines of code as below for valuation type and fund center to be default values.
Here I am facing one issue.
You can see in debugging FISTL is by default 'DUMMY'. which I am overwriting with the line no 118 in the code as P02205. When the line is executed I can see LS_EREQITEM-FISTL as P02205 as shown below.
But when I press F8 I can see on the screen INDIAN in BWTAR as expected but I am getting only DUMMY on the ME51N SCREEN . Ideally P02205 should have reflected on the screen. Any reason though it is overwritting DUMMY with P02205 in debugging , but still gettting DUMMY on the screen.
Thanks for your assistance.
2023 Nov 07 12:52 PM
2023 Nov 08 1:36 PM
Hi, Raymond, I have added the new code related to set_datax but still getting DUMMY on the screen
I have no idea why the value of 'p02205' is not appearing on the screen. I have checked the data types also. Everyting is fine.
2023 Nov 08 2:01 PM
Add this code (look at my sample/pattern)
ls_mereqitemx-bwtar = abap_true.
ls_mereqitemx-fistl = abap_true.
2023 Nov 08 2:25 PM
I have added it here but no luck. Still I can able to see the previous value on the screen field.
2023 Nov 08 2:29 PM
I was going through this issue in website and many were facing the same issue but there is no clear cut explanation of how to fix the issue . Do you think we have to look for any user exit to get this issue resolved ?
DATA : w_netpr TYPE eine-netpr,
ls_mereqitem TYPE mereq_item, IF sy-tcode = 'ME51N'.
DATA(ls_mereqitem1) = ls_mereqitem.
IF ls_mereqitem1-matnr IS NOT INITIAL.
ls_mereqitem1-matnr = |{ ls_mereqitem1-matnr ALPHA = OUT }|.
SELECT SINGLE * FROM zmrp_items INTO @DATA(ls_mrpitems) WHERE matnr = @ls_mereqitem1-matnr.
IF ls_mrpitems IS NOT INITIAL.
CLEAR ls_mereqitem1-fistl .
CLEAR ls_mereqitem-fistl .
ls_mereqitem1-bwtar = 'INDIAN'.
ls_mereqitem1-fistl = 'P02205'.
ls_mereqitem-bwtar = ls_mereqitem1-bwtar.
ls_mereqitem-fistl = ls_mereqitem1-fistl.
ls_mereqitemx-bwtar = abap_true.
ls_mereqitemx-fistl = abap_true.
CALL METHOD im_item->set_data
EXPORTING
im_data = ls_mereqitem.
CALL METHOD im_item->set_dataX
EXPORTING
im_dataX = ls_mereqitemX.
ENDIF.
ENDIF.
ENDIF.
2023 Nov 08 3:53 PM
After searching
2023 Nov 09 9:30 PM
Thanks Raymond , I have achieved what I am looking for by using PROCESS_ACCOUNT . However, I am very much eager and enthsisatic to achieve the same from PROCESS_ITEM .
can you please help me code for this part.
"or access accountings from item in PROCESS_ITEM with IF_ACCT_CONTAINER_MM~GET_ITEMS, LOOP, GET_DATA, SET_DATA)"
2023 Nov 10 10:44 AM
You can find a sample on access to account from item in this blog and those questions.
2023 Nov 09 9:32 PM
Hi, I am posting this as it would be reference for those who will go through this thread.
with the above code I can able to default funds center value.
2023 Nov 10 10:18 AM
I am facing issue in PROCESS_ACCOUNT as in import there is no field of MATNR so I can not able to apply where clause based on MATNR in select query as shown above pic. This leads to p02205 coming for all material numbers.
So I have to fix this issue in PROCESS_ITEM as Raymond has mentioned about access accountings from item in PROCESS_ITEM with IF_ACCT_CONTAINER_MM~GET_ITEMS, LOOP, GET_DATA, SET_DATA)"