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: 

me51n default value for Valuation type and funds center

pashasapcha
Participant
0 Kudos
1,652

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 ?

16 REPLIES 16

raymond_giuseppi
Active Contributor
0 Kudos
1,432

Did you try with methods of BAdI ME_PROCESS_REQ_CUST such as PROCESS_ACCOUNT ?

0 Kudos
1,432

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.

0 Kudos
1,432
  • This customer-exit is relevant for release strategy.
  • The BAdI provide much more options.

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.

0 Kudos
1,432

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. ?

0 Kudos
1,432

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.

0 Kudos
1,432

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.

0 Kudos
1,432

You forget to call the set_datax method?

0 Kudos
1,432

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.

0 Kudos
1,432

Add this code (look at my sample/pattern)

ls_mereqitemx-bwtar = abap_true.
ls_mereqitemx-fistl = abap_true.

0 Kudos
1,432

I have added it here but no luck. Still I can able to see the previous value on the screen field.

0 Kudos
1,432

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,
ls_mereqitemx TYPE mereq_itemx,
w_matnr TYPE mara-matnr.
DATA : l_lastpo TYPE ekpo-netpr,
l_infnr TYPE eina-infnr,
i_eina TYPE TABLE OF eina,
wa_eina TYPE eina,
i_eine TYPE TABLE OF eine,
wa_eine TYPE eine.
DATA lv_date_diff TYPE p.
CLEAR: ls_mereqitem.
ls_mereqitem = im_item->get_data( ).
ls_mereqitemx = im_item->get_datax( ).

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.

1,432

After searching

  • I don't see field FISTL in structure MEREQ_ITEM_S_CUST_ALLOWED 'PReq Fields That Can Be Modified via User Exit' - Can you check for your version?
  • You could try a get_data after set_data and set_datax for testing purpose
  • You should try to set FISTL in PROCESS_ACCOUNT (as in my initial answer...) or access accountingss from item in PROCESS_ITEM with IF_ACCT_CONTAINER_MM~GET_ITEMS, LOOP, GET_DATA, SET_DATA)

0 Kudos
1,432

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)"

0 Kudos
1,432

You can find a sample on access to account from item in this blog and those questions.

pashasapcha
Participant
0 Kudos
1,431

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.

0 Kudos
1,431

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)"