‎2006 Nov 17 8:33 PM
Urgent!!!
Do we have any BAPI for changing the Standard price of a material in MM02 in the Accounting view???
Shekar.
‎2006 Nov 17 9:03 PM
Here is a simple example program which will help you code it.
report zrich_0003 .
data: headdata type bapimathead.
data: valdata type bapi_mbew.
data: valdatax type bapi_mbewx.
data: return type bapiret2 .
data: returnm type table of bapi_matreturn2 with header line.
data: xmara type mara.
parameters: p_matnr type mbew-matnr,
p_bwkey type mbew-bwkey,
p_bwtar type mbew-bwtar,
p_stprs type mbew-stprs.
select single * from mara into xmara
where matnr = p_matnr.
headdata-material = xmara-matnr.
headdata-ind_sector = xmara-mbrsh.
headdata-matl_type = xmara-mtart.
headdata-account_view = 'X'.
valdata-val_area = p_bwkey.
valdata-val_type = p_bwtar.
valdata-std_price = p_stprs.
valdatax-val_area = p_bwkey.
valdatax-val_type = p_bwtar.
valdatax-std_price = 'X'.
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = headdata
valuationdata = valdata
valuationdatax = valdatax
importing
return = return
tables
returnmessages = returnm.
check sy-subrc = 0.
Regards,
Rich Heilman
‎2006 Nov 17 8:35 PM
check the tcode BAPI & expand the MM node on the left hand side.. you will get alist of all the vaialble BAPIs..
~Suresh
‎2006 Nov 17 8:36 PM
‎2006 Nov 17 8:44 PM
Hi Shekar,
You can use BAPI BAPI_MATERIAL_SAVEDATA.
Hope this will help.
Regards,
Ferry Lianto
‎2006 Nov 17 9:03 PM
Here is a simple example program which will help you code it.
report zrich_0003 .
data: headdata type bapimathead.
data: valdata type bapi_mbew.
data: valdatax type bapi_mbewx.
data: return type bapiret2 .
data: returnm type table of bapi_matreturn2 with header line.
data: xmara type mara.
parameters: p_matnr type mbew-matnr,
p_bwkey type mbew-bwkey,
p_bwtar type mbew-bwtar,
p_stprs type mbew-stprs.
select single * from mara into xmara
where matnr = p_matnr.
headdata-material = xmara-matnr.
headdata-ind_sector = xmara-mbrsh.
headdata-matl_type = xmara-mtart.
headdata-account_view = 'X'.
valdata-val_area = p_bwkey.
valdata-val_type = p_bwtar.
valdata-std_price = p_stprs.
valdatax-val_area = p_bwkey.
valdatax-val_type = p_bwtar.
valdatax-std_price = 'X'.
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = headdata
valuationdata = valdata
valuationdatax = valdatax
importing
return = return
tables
returnmessages = returnm.
check sy-subrc = 0.
Regards,
Rich Heilman
‎2006 Nov 17 11:44 PM
Thanks for the info RICH!
But when I modify your code as per my requirement and use it in the following way where in the Material numbers for which I got to modify the standad price to 777 come from my Internal table I_Itab, it doesn't work.
could you please help me in findng it out like WHY????? it doesnt populate the standard price as 777 eventhough it executes with out any error..
data: headdata type bapimathead.
data: valdata type bapi_mbew.
data: valdatax type bapi_mbewx.
data: return type bapiret2 .
data: returnm type table of bapi_matreturn2 with header line.
Loop at I_ItabS.
headdata-material = I_ItabS-matnr.
valdata-std_price = '777'.
valdatax-std_price = '777'.
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = headdata
valuationdata = valdata
valuationdatax = valdatax
importing
return = return
tables
returnmessages = returnm.
Endloop.
‎2006 Nov 18 1:43 AM
It could be a COMMIT issue..you can put a function call to BAPI_TRANSACTION_COMMIT after the original BAPI.
~Suresh
‎2006 Nov 18 2:53 AM
The reason is that you are not setting the "X" structure correctly, eash structure has an "X" structure where you are telling the BAPI that you want to modify that specific field.
You have....
valdata-std_price = '777'.
valdatax-std_price = '777'.
Make it like this.
valdata-std_price = '777'.
valdatax-std_price = 'X'.
Regards,
RIch Heilman
‎2006 Nov 18 4:00 AM
Ya Rich!
I tried it. But it does the same.
Anything else we can do?
‎2006 Nov 20 3:15 AM
Thanks RICH!!
I got it this time.
I didn't knew that BWKEY is mandatory, which was my mistake.
Anyways thank you once again.
‎2006 Nov 20 2:02 PM
‎2006 Nov 18 4:06 AM
Hi,
Were you able to manually change the standard price in MM02??
Thanks,
Naren
‎2006 Nov 18 4:08 AM
yes I can change the Stnd price manually through MM02.
I donnow where I'm missing.
Its really annoying!
‎2006 Nov 18 4:57 AM
Hi,
Did you try Rich's code??Also add commit work..at the end ..
report zrich_0003 .
data: headdata type bapimathead.
data: valdata type bapi_mbew.
data: valdatax type bapi_mbewx.
data: return type bapiret2 .
data: returnm type table of bapi_matreturn2 with header line.
data: xmara type mara.
parameters: p_matnr type mbew-matnr,
p_bwkey type mbew-bwkey,
p_bwtar type mbew-bwtar,
p_stprs type mbew-stprs.
select single * from mara into xmara
where matnr = p_matnr.
headdata-material = xmara-matnr.
headdata-ind_sector = xmara-mbrsh.
headdata-matl_type = xmara-mtart.
headdata-account_view = 'X'.
valdata-val_area = p_bwkey.
valdata-val_type = p_bwtar.
valdata-std_price = p_stprs.
valdatax-val_area = p_bwkey.
valdatax-val_type = p_bwtar.
valdatax-std_price = 'X'.
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = headdata
valuationdata = valdata
valuationdatax = valdatax
importing
return = return
tables
returnmessages = returnm.
check sy-subrc = 0.
<b>COMMIT WORK.</b>
Thanks,
Naren