‎2010 Feb 03 1:15 PM
Hi Gurus,
I am trying to create material using BAPI '/AFS/BAPI_MATERIAL_SAVEDATA'.
When I am executing the BAPI from code it is giving error 'No description Transferred'. Error 148 from message class 'MG'
But when I test the BAPI from SE37 it works fine.
‎2010 Feb 22 10:42 AM
remember to populate the "materialdescription" table passed to the BAPI
i copied my source code below.
Please note that you would need to adjust the code to your configuration on your system. As the material types, distribution channels, plants, storagelocation etc, might differ.
Hope it helps.
MATERIAL HEADER DATA
st_mat_head-material = 'MATERIAL'. " MATERIAL NUMBER
st_mat_head-ind_sector = 'M'. " MECHANICAL ENGINERING
st_mat_head-matl_type = 'VEHI'. " VEHICLE CONFIG
st_mat_head-basic_view = 'X'.
st_mat_head-sales_view = 'X'.
st_mat_head-purchase_view = 'X'.
st_mat_head-mrp_view = 'X'.
st_mat_head-forecast_view = 'X'.
st_mat_head-work_sched_view = 'X'.
st_mat_head-prt_view = 'X'.
st_mat_head-storage_view = 'X'.
st_mat_head-warehouse_view = 'X'.
st_mat_head-quality_view = 'X'.
st_mat_head-account_view = 'X'.
st_mat_head-cost_view = 'X'.
MATERIAL CLIENT DATA (BASIC DATA)
st_mat_client-matl_group = 'RRS'. " DATA TO BE FOUND FROM BRANDSYMPHONY - Product Range Code mapping
st_mat_client-base_uom = 'ST'.
st_mat_client-unit_of_wt = 'KG'.
st_mat_client-item_cat = '0002'. "Use configuration
st_mat_client-trans_grp = '0001'. "TRANSPROTATION GROUP
st_mat_clientx-matl_group = 'X'.
st_mat_clientx-base_uom = 'X'.
st_mat_clientx-unit_of_wt = 'X'.
st_mat_clientx-item_cat = 'X'.
st_mat_clientx-trans_grp = 'X'.
MATERIAL PLANT DATA (MRP)
st_mat_plant-plant = '1000'. " DATA TO BE DETERMINED OFF THE NSC MASTER and mapping between Brandsymphomy - Marque field
st_mat_plant-mrp_type = 'ND'. " NO PLANNING
st_mat_plant-proc_type = 'X'. " PROCUREMENT TYPE
st_mat_plant-period_ind = 'M'. " PERIOD INDICATOR = M FOR MONTHLY
st_mat_plant-availcheck = 'KP'. " AVAILABILITY CHECK = KP FOR NO CHECK
st_mat_plant-profit_ctr = '0000001900'.
st_mat_plant-loadinggrp = '0001'.
st_mat_plantx-plant = '1000'.
st_mat_plantx-mrp_type = 'X'.
st_mat_plantx-proc_type = 'X'.
st_mat_plantx-period_ind = 'X'.
st_mat_plantx-availcheck = 'X'.
st_mat_plantx-profit_ctr = 'X'.
st_mat_plantx-loadinggrp = 'X'.
MATERIAL FORECAST PARAMETERS (FORECASTING)
st_mat_fcpar-plant = '1000'.
st_mat_fcpar-fore_model = 'N'. " FORECAST MODEL = N FOR NO FORECAST MODEL
st_mat_fcpar-model_sp = '2'. "MODEL SELECTION PROCEDURE = 2 FOR Analytical Model selection procedure
st_mat_fcpar-hist_vals = '60'. "NUMBER OF HISTORICAL PERIODS
st_mat_fcpar-fore_pds = '12'. " NUMBER OF FORECAST PERIODS
st_mat_fcpar-initialize = 'X'. " INITIALIZATION INDICATOR
st_mat_fcpar-tracklimit = '4'. " TRACKING LIMIT
st_mat_fcparx-plant = '1000'.
st_mat_fcparx-fore_model = 'X'.
st_mat_fcparx-model_sp = 'X'.
st_mat_fcparx-hist_vals = 'X'.
st_mat_fcparx-fore_pds = 'X'.
st_mat_fcparx-initialize = 'X'.
st_mat_fcparx-tracklimit = 'X'.
MATERIAL STORAGE LOCATION (PLANT/STORAGE)
st_mat_sloc-plant = '1000'.
st_mat_sloc-stge_loc = 'LNEW'. "STORAGE LOCATION TO BE GATHERED FROM NSC MASTER
st_mat_slocx-plant = '1000'.
st_mat_slocx-stge_loc = 'LNEW'.
MATERIAL VALUATION (ACCOUNTING)
st_mat_val-val_class = '8100'. "DATA TO BE DETERMINED FROM NSC MASTER
st_mat_val-vm_so_stk = '8100'.
st_mat_val-val_area = '1000'. "MAINTAINED IN CONFIG ALSO IN TABLE T001K-BWKEY
st_mat_val-val_cat = 'X'. " VALUATION CATEGORY INDICATOR
st_mat_val-price_ctrl = 'V'. " NOT USING STANDARD PRICING
st_mat_val-price_unit = '1'. " PRICING UNIT
st_mat_valx-val_area = '1000'.
st_mat_valx-val_class = 'X'.
st_mat_valx-val_cat = 'X'.
st_mat_valx-price_ctrl = 'X'.
st_mat_valx-price_unit = 'X'.
st_mat_valx-vm_so_stk = 'X'.
MATERIAL SALES (SALES ORG)
st_mat_sales-sales_org = '1000' ."SALES ORGANIZATION
st_mat_sales-distr_chan = '10'. " DISTRIBUTION CHANNEL
st_mat_sales-cash_disc = 'X'. "CASH DISCOUNT INDICATOR
st_mat_sales-item_cat = '0002'. " DETERMINED ON CONFIG
st_mat_salesx-sales_org = '1000'.
st_mat_salesx-distr_chan = '10'.
st_mat_salesx-cash_disc = 'X'.
st_mat_salesx-item_cat = 'X'.
i_mat_des-matl_desc = 'MODEL DESCRIPTION FOR NEW VEHICLE'.
i_mat_des-langu = sy-langu.
APPEND i_mat_des.
i_mat_uom-alt_unit = 'ST'.
APPEND i_mat_uom.
i_mat_uomx-alt_unit = 'ST'.
APPEND i_mat_uomx.
i_mat_taxclass-taxclass_1 = '1'. "DEPENDANT ON NSC
i_mat_taxclass-tax_type_1 = 'MWST'. " TAX CLASSIFICATION TYPE
i_mat_taxclass-depcountry = 'ZA'. "COUNTRY TO BE DERIVED FROM NSC
APPEND i_mat_taxclass.
PERFORM call_material_bapi.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = st_mat_head
clientdata = st_mat_client
clientdatax = st_mat_clientx
plantdata = st_mat_plant
plantdatax = st_mat_plantx
forecastparameters = st_mat_fcpar
forecastparametersx = st_mat_fcparx
storagelocationdata = st_mat_sloc
storagelocationdatax = st_mat_slocx
valuationdata = st_mat_val
valuationdatax = st_mat_valx
warehousenumberdata = st_mat_whdata
warehousenumberdatax = st_mat_whdatax
salesdata = st_mat_sales
salesdatax = st_mat_salesx
storagetypedata = st_mat_store
storagetypedatax = st_mat_storex
IMPORTING
return = st_mat_ret
TABLES
materialdescription = i_mat_des
unitsofmeasure = i_mat_uom
unitsofmeasurex = i_mat_uomx
taxclassifications = i_mat_taxclass
returnmessages = i_mat_return.
COMMIT WORK AND WAIT.