BAPI_MATERIAL_SAVEREPLICA Batch maintenance of material master data
BAPI_MATERIAL_SAVEDATA single maintenance (for example, the storage location is also maintained by a factory and a storage location)
If the material already has a cost, and then maintain the price of the material, an error M8 155 will be reported, "The standard cost is estimated to exist in the period 12 2016", which means that the cost cannot be maintained in mm02 and needs to be maintained in mr21.
Create a classification view with BAPI_OBJCL_CREATE
If you want to write the user name, change sy-uname, the user can also write in if the user does not exist in sap
demo
function zwm_xxx_material_update.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_MATNR) TYPE MATNR
*" EXPORTING
*" VALUE(RTYPE) TYPE BAPI_MTYPE
*" VALUE(RTMSG) TYPE BAPI_MSG
*" TABLES
*" T_DATA STRUCTURE ZWM_S_XXX_MATERIAL_UPDATE
*"----------------------------------------------------------------------
zfmparavalsave1 'ZWM_XXX_MATERIAL_UPDATE'.
zfmparavalsave2 'B'.
perform frm_matn1_input changing iv_matnr.
read table t_data index 1.
data ls_headdata type bapimathead.
data ls_clientdata type bapi_mara.
data ls_clientdatax type bapi_marax.
data ls_warehousenumberdata type bapi_mlgn.
data ls_warehousenumberdatax type bapi_mlgnx.
data ls_return type bapiret2.
data lt_unitsofmeasure type standard table of bapi_marm with header line.
data lt_unitsofmeasurex type standard table of bapi_marmx with header line.
data lt_returnmessages type standard table of bapi_matreturn2 with header line.
ls_headdata-material = iv_matnr.
ls_clientdata-size_dim = t_data-groes. "Size/dimensions
ls_clientdata-net_weight = t_data-ntgew. "Net Weight
ls_clientdatax-size_dim = 'X'.
ls_clientdatax-net_weight = 'X'.
select single meins,gewei
into @data(ls_mara)
from mara
where matnr = @iv_matnr.
lt_unitsofmeasure-alt_unit = ls_mara-meins.
lt_unitsofmeasure-gross_wt = t_data-brgew. "Gross Weight
append lt_unitsofmeasure.
lt_unitsofmeasurex-alt_unit = ls_mara-meins.
lt_unitsofmeasurex-gross_wt = 'X'.
append lt_unitsofmeasurex.
ls_warehousenumberdata-whse_no = t_data-lgnum. "Warehouse Number / Warehouse Complex
ls_warehousenumberdata-placement = t_data-ltkze. "Storage type indicator for stock placement
ls_warehousenumberdata-withdrawal = t_data-ltkza. "Storage type indicator for stock removal
ls_warehousenumberdatax-whse_no = t_data-lgnum.
ls_warehousenumberdatax-placement = 'X'.
ls_warehousenumberdatax-withdrawal = 'X'.
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = ls_headdata
clientdata = ls_clientdata
clientdatax = ls_clientdatax
warehousenumberdata = ls_warehousenumberdata
warehousenumberdatax = ls_warehousenumberdatax
importing
return = ls_return
tables
unitsofmeasure = lt_unitsofmeasure
unitsofmeasurex = lt_unitsofmeasurex
returnmessages = lt_returnmessages.
if ls_return-type = 'A' or ls_return-type = 'E' or ls_return-type = 'X'.
call function 'BAPI_TRANSACTION_ROLLBACK'.
loop at lt_returnmessages where type ca 'AEX'.
rtype = 'E'.
message id lt_returnmessages-id type lt_returnmessages-type number lt_returnmessages-number
with lt_returnmessages-message_v1 lt_returnmessages-message_v2
lt_returnmessages-message_v3 lt_returnmessages-message_v4
into data(lv_msg).
rtmsg = rtmsg && lv_msg && ';'.
endloop.
else.
rtype = 'S'.
rtmsg = 'success'.
endif.
zfmparavalsave2 'R'.
endfunction.