‎2007 Jul 30 11:47 AM
Hi to everyone.
I'm using BAPI_MATERIAL_SAVEDATA to duplicate some material (basically I want to create a copy of a material but changing the PLANT). Should I inform all the fields or just the material number in the headdata and the new plant?
Thanks
carles
‎2007 Jul 30 11:48 AM
See the sample code.....
report zrich_0003 .
data: headdata type bapimathead.
data: clientdata type bapi_mara.
data: clientdatax type bapi_marax.
data: descdata type table of BAPI_MAKT with header line.
data: return type bapiret2 .
data: returnm type table of bapi_matreturn2 with header line.
data: xmara type mara.
parameters: p_matnr type mara-matnr.
headdata-material = p_matnr.
headdata-ind_sector = 'M'.
headdata-matl_type = 'FERT'.
headdata-basic_view = 'X'.
clientdata-BASE_UOM = 'EA'.
clientdatax-BASE_UOM = 'X'.
clientdata-old_mat_no = 'Old Material'.
clientdatax-old_mat_no = 'X'.
clientdata-division = '00'.
clientdatax-division = 'X'.
descdata-LANGU = sy-langu.
descdata-MATL_DESC = 'This is the description'.
append descdata.
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = headdata
clientdata = clientdata
clientdatax = clientdatax
PLANTDATA =
PLANTDATAX =
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA =
STORAGELOCATIONDATAX =
VALUATIONDATA =
VALUATIONDATAX =
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA =
SALESDATAX =
STORAGETYPEDATA =
STORAGETYPEDATAX =
importing
return = return
tables
MATERIALDESCRIPTION = descdata
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
returnmessages = returnm
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
.
check sy-subrc = 0.
Check these links........
Regards,
Pavan
‎2007 Jul 30 11:49 AM
‎2007 Jul 30 11:52 AM
‎2007 Jul 30 11:57 AM
Before calling the BAPI_MATERIAL_SAVEDATA, I recover the material data using BAPI_MATERIAL_GET_ALL.
Then I do MOVE-CORRESPONDING to move data from the clientdata and plantdata wa recovered to the headdata, clientdata and plantdata wa that I need to inform BAPI_MATERIAL_SAVEDATA. Then I need to fill the clientdatax and plantdatax wa, but the fields informed may vary depending on the material (the delete flag may or may not be marked...), and I suppose the better way to inform the clientdatax and plantdatax wa would be filling all their fields, but how can I do that?
thanks.
carles