‎2006 Dec 31 2:27 PM
Hi folks,
im working on BAPI_MATERIAL_SAVEDATA and trying to update Standard Price of material .
im trying to change its value in the valuation data and valuationdatax structure.
the result is that data is changed infm im recieving, but when i check it in MM03 only the moving price is getting updated but not the standard price.
i have also use
MY_MATERIAL_PRICE_UPDATE
MY_MATERIAL_PRICE_CHANGE
but there are not giving the result.
Please help if anyone has worked on it.
any other FMs for this is also appreciated.
‎2006 Dec 31 3:22 PM
Hi,
Please check this sample code.
report ztest.
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.
Also please check FM CKML_UPDATE_MATERIAL_PRICE.
Hope this will help.
Regards,
Ferry Lianto
‎2006 Dec 31 3:51 PM
‎2007 Jan 02 6:25 AM
Hi rich and ferry,
thankls for ur reply....
i already have this code much is not solving my problem.....
as of now im using MR21 transaction manually but im looking fo rthis type of code...
i tried executing the bapi manually but only moving price is getting updated but not the std price i used commit work also but is of no use.
im taking care in updating field of valuation datax structure also ....
please help...
also BWkey is also populated but of no use......it is really urgent plz help me
‎2007 Jan 02 6:38 PM
‎2007 Jan 03 6:18 AM
Hi rich,
TABLES: mara, "General Material Data
mbew, "Material Valuation
zkt_cbht. "Cost Blending History Table
DATA: gt_cbht TYPE TABLE OF zkt_cbht INITIAL SIZE 0.
DATA: gs_bapi_head TYPE bapimathead, "Header Data
gs_bapi_mbew1 TYPE bapi_mbew, "Accounting View Data
gs_bapi_mbewx TYPE bapi_mbewx,
bapi_return TYPE bapiret2,
gs_cbht TYPE zkt_cbht. "Cost Blending History Table
*Populate the internal table.
Select *
from zkt_cbht
into table gt_cbht.
*Read all the table entries of ZKT_CBHT and update the
*Material master data.
LOOP AT gt_cbht INTO gs_cbht.
Header
gs_bapi_head-material = gs_cbht-matnr.
gs_bapi_head-basic_view = 'X'.
gs_bapi_head-purchase_view = 'X'.
gs_bapi_head-account_view = 'X'.
Accounting
gs_bapi_mbew1-val_area = gs_cbht-werks.
gs_bapi_mbew1-price_ctrl = 'S'.
gs_bapi_mbew1-std_price = gs_cbht-stprs.
Accounting X data
gs_bapi_mbewx-val_area = gs_cbht-werks.
gs_bapi_mbewx-price_ctrl = 'X'.
gs_bapi_mbewx-std_price = 'X'.
*Upadte the the Standard Price.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = gs_bapi_head
valuationdata = gs_bapi_mbew1
valuationdatax = gs_bapi_mbewx
IMPORTING
return = bapi_return.
*Save the New Price Change.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
ENDLOOP.
here my table zkt_cbht table has the fields like werks and std price.
Message was edited by:
Durgaprasad Kare
‎2007 Jan 12 4:13 PM
‎2007 Jan 02 6:43 PM
Hi,
Go to MM02..And try to manually change the standard price..If you were able to do it..I believe you can do it in BAPI also..
Thanks,
Naren
‎2007 Jan 12 4:15 PM
i have used a different function module to over come my problem.
the FM is mb_material_price_update.
apart from this u can go with BDC else u will not get the required .i was not successful using BAPI_MATERIAL_SAVEDATA.