‎2012 Feb 08 8:48 AM
When I try to create a material using BAPI_MATERIAL_SAVEDATA: , all the fields are getting updated except Gross weight in the tab 'Basic Data1' . When I searched for a solution I found the problem will be resolved when I fill Alternate Unit(ALT_UNIT)with the same value as in Base Unit of Measurement in my BAPI structures.
But my requirement is, the value of ALT_UNIT & Base UOM should be different.
‎2012 Feb 08 11:04 AM
Hi Rakhi Nair,
While creating material you should pass all mandatory fields,like
in Import tab:
HEADDATA in this
MATERIAL
IND_SECTOR
MATL_TYPE
BASIC_VIEW(any view)
CLIENTDATA in this
BASE_UOM_ISO
in Tables tab:
MATERIALDESCRIPTION in this
LANGU
MATL_DESC
UNITSOFMEASURE in this
GROSS_WT(your required field)
UNITSOFMEASUREX in this
GROSS_WT as X and create material
Regards,
Ravindra.
Edited by: chundruravindra on Feb 8, 2012 12:07 PM
‎2012 Feb 08 11:04 AM
Hi Rakhi Nair,
While creating material you should pass all mandatory fields,like
in Import tab:
HEADDATA in this
MATERIAL
IND_SECTOR
MATL_TYPE
BASIC_VIEW(any view)
CLIENTDATA in this
BASE_UOM_ISO
in Tables tab:
MATERIALDESCRIPTION in this
LANGU
MATL_DESC
UNITSOFMEASURE in this
GROSS_WT(your required field)
UNITSOFMEASUREX in this
GROSS_WT as X and create material
Regards,
Ravindra.
Edited by: chundruravindra on Feb 8, 2012 12:07 PM
‎2012 Feb 09 6:11 AM
My material is already created with all the required data.. but the issue is with the GROSS WGT. The Gross wgt field is not getting updated. I tried and i will get updated once we give Base UOM and ALT_UNIT are same. But in my requirement , those 2 values are different...
‎2012 Feb 09 7:01 AM
Hi,
in the same way i created material GrossWeight field got updated, tell me any other conditions do u have.
‎2012 Feb 08 1:01 PM
Hi,
let us try the following code i got it
data : lt_filetable type filetable,
ls_filetable like line of lt_filetable,
lv_rc type i.
types : begin of ty_legacy,
str(100) type c,
end of ty_legacy.
data : lt_legacy type standard table of ty_legacy,
ls_legacy type ty_legacy.
data path type string.
types : begin of ty_material,
material type BAPIMATHEAD-material,
IND_SECTOR type BAPIMATHEAD-ind_sector,
MATL_TYPE type BAPIMATHEAD-matl_type,
MATL_GROUP type BAPI_MARA-matl_group,
BASE_UOM type BAPI_MARA-base_uom,
LANGU type BAPI_MAKT-langu,
LANGU_ISO type BAPI_MAKT-langu_iso,
MATL_DESC type BAPI_MAKT-matl_desc,
end of ty_material.
data : lt_material type standard table of ty_material,
ls_material type ty_material.
data : ls_bapimathead type BAPIMATHEAD,
ls_bapi_mara type BAPI_MARA,
ls_bapi_marax type BAPI_MARAX,
ls_return type BAPIRET2.
data : lt_bapi_makt type table of BAPI_MAKT,
ls_bapi_makt type BAPI_MAKT.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
CHANGING
FILE_TABLE = lt_filetable
RC = lv_rc.
if lt_filetable is not initial.
read table lt_filetable into ls_filetable index 1.
if sy-subrc eq 0.
path = ls_filetable-filename.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = path
FILETYPE = 'ASC'
CHANGING
DATA_TAB = lt_legacy[].
endif.
endif.
if lt_legacy[] is not initial.
loop at lt_legacy into ls_legacy.
split ls_legacy-str at ',' into
ls_material-material
ls_material-ind_sector
ls_material-matl_type
ls_material-matl_group
ls_material-base_uom
ls_material-langu
ls_material-langu_iso
ls_material-matl_desc.
append ls_material to lt_material.
endloop.
endif.
if lt_material[] is not initial.
loop at lt_material into ls_material.
prepare Header data
clear ls_bapimathead.
ls_bapimathead-MATERIAL = ls_material-MATERIAL.
ls_bapimathead-IND_SECTOR = ls_material-IND_SECTOR.
ls_bapimathead-MATL_TYPE = ls_material-MATL_TYPE.
ls_bapimathead-BASIC_VIEW = 'X'.
prepare bapi_mara parameter
clear ls_bapi_mara.
ls_bapi_mara-MATL_GROUP = ls_material-MATL_GROUP.
ls_bapi_mara-BASE_UOM = ls_material-BASE_UOM.
prepare bapi_marax parameter
clear ls_bapi_marax.
ls_bapi_marax-MATL_GROUP = 'X'.
ls_bapi_marax-BASE_UOM = 'X'.
prepare BAPI_MAKT internal table
clear ls_bapi_makt.
refresh lt_bapi_makt.
ls_bapi_makt-LANGU = ls_material-LANGU.
ls_bapi_makt-LANGU_ISO = ls_material-LANGU_ISO.
ls_bapi_makt-MATL_DESC = ls_material-MATL_DESC.
append ls_bapi_makt to lt_bapi_makt.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = ls_bapimathead
CLIENTDATA = ls_bapi_mara
CLIENTDATAX = ls_bapi_marax
IMPORTING
RETURN = ls_return
TABLES
MATERIALDESCRIPTION = lt_bapi_makt.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
write 😕 ls_material-material,
ls_return-type,
ls_return-message.
clear : ls_return,
ls_material.
endloop.
endif.
Thanks & Regards,
Raghunadh .K
‎2012 Feb 09 6:12 AM