Skip to Content
0
Former Member
Sep 20, 2007 at 11:21 AM

BAPI_MATERIAL_SAVEDATA

290 Views

Hi Gurus,

I'm using the above BAPI to create materials...The problem is that the BAPI is not creating any sales data for me.

Sales: Sales Org. Data 1

Sales: Sales Org. Data 2

Sales: General/Plant Data

These 3 views are not getting created even though I've populated the sales views...Any ideas why ? Any help would be appreciated. I've pasted my code here...

******************************************************************************

LOOP AT it_matmaster.

CLEAR: it_return[], it_return1[], it_return,it_return1.

lv_counter = lv_counter + 1.

*-- Header data

bapimathead-material = it_matmaster-matnr.

bapimathead-ind_sector = it_matmaster-mbrsh.

bapimathead-matl_type = it_matmaster-mtart.

*-- Select the views

bapimathead-basic_view = c_selected.

bapimathead-sales_view = c_selected.

bapimathead-purchase_view = c_selected.

bapimathead-mrp_view = c_selected.

bapimathead-storage_view = c_selected.

bapimathead-account_view = c_selected.

bapimathead-cost_view = c_selected.

*-- Client data

bapi_mara-matl_group = it_matmaster-matkl.

bapi_mara-base_uom = it_matmaster-meins.

bapi_mara-unit_of_wt = it_matmaster-gewei.

  • bapi_mara-item_cat = it_matmaster-mtpos.

bapi_mara-trans_grp = it_matmaster-tragr.

bapi_mara-pur_status = it_matmaster-mstae.

bapi_marax-matl_group = c_selected.

bapi_marax-base_uom = c_selected.

bapi_marax-unit_of_wt = c_selected.

  • bapi_marax-item_cat = c_selected.

bapi_marax-trans_grp = c_selected.

bapi_marax-pur_status = c_selected.

*-- Plant data

bapi_marc-plant = it_matmaster-werks.

bapi_marc-pur_group = it_matmaster-ekgrp.

bapi_marc-availcheck = it_matmaster-mtvfp.

bapi_marc-loadinggrp = it_matmaster-ladgr.

bapi_marc-mrp_group = it_matmaster-disgr.

bapi_marc-mrp_type = it_matmaster-dismm.

bapi_marc-mrp_ctrler = it_matmaster-dispo.

bapi_marc-lotsizekey = it_matmaster-disls.

bapi_marc-reorder_pt = it_matmaster-minbe.

bapi_marc-sloc_exprc = it_matmaster-lgfsb.

bapi_marc-plnd_delry = it_matmaster-plifz.

bapi_marc-sm_key = it_matmaster-fhori.

bapi_marc-safety_stk = it_matmaster-eisbe.

bapi_marc-lot_size = it_matmaster-losgr.

bapi_marc-minlotsize = it_matmaster-bstmi.

bapi_marcx-plant = it_matmaster-werks.

bapi_marcx-pur_group = c_selected.

bapi_marcx-availcheck = c_selected.

bapi_marcx-loadinggrp = c_selected.

bapi_marcx-mrp_group = c_selected.

bapi_marcx-mrp_type = c_selected.

bapi_marcx-mrp_ctrler = c_selected.

bapi_marcx-lotsizekey = c_selected.

bapi_marcx-reorder_pt = c_selected.

bapi_marcx-sloc_exprc = c_selected.

bapi_marcx-plnd_delry = c_selected.

bapi_marcx-sm_key = c_selected.

bapi_marcx-lot_size = c_selected.

bapi_marcx-minlotsize = c_selected.

*-- Storage Location data

bapi_mard-plant = it_matmaster-werks.

bapi_mard-stge_loc = it_matmaster-lgort.

bapi_mard-stge_bin = it_matmaster-lgpbe.

bapi_mardx-plant = it_matmaster-werks.

bapi_mardx-stge_loc = it_matmaster-lgort.

bapi_mardx-stge_bin = c_selected.

*-- Valuation data

bapi_mbew-val_area = it_matmaster-werks.

bapi_mbew-val_class = it_matmaster-bklas.

bapi_mbew-price_ctrl = it_matmaster-vprsv.

bapi_mbew-price_unit = it_matmaster-peinh.

bapi_mbew-moving_pr = it_matmaster-verpr.

bapi_mbew-std_price = it_matmaster-stprs.

bapi_mbewx-val_area = it_matmaster-werks.

bapi_mbewx-val_class = c_selected.

bapi_mbewx-price_ctrl = c_selected.

bapi_mbewx-price_unit = c_selected.

bapi_mbewx-moving_pr = c_selected.

bapi_mbewx-std_price = c_selected.

*-- Sales data

bapi_mvke-sales_org = it_matmaster-vkorg.

bapi_mvke-distr_chan = it_matmaster-vtweg.

bapi_mvke-item_cat = it_matmaster-mtpos.

bapi_mvkex-sales_org = it_matmaster-vkorg.

bapi_mvkex-distr_chan = it_matmaster-vtweg.

bapi_mvkex-item_cat = c_selected.

*-- Tax Classification data

bapi_mlan-taxclass_1 = it_matmaster-taxkm.

*-- Material descriptions

it_materialdesc-langu = 'EN'.

it_materialdesc-matl_desc = it_matmaster-maktx.

APPEND it_materialdesc.

it_mltx-langu = 'E'.

it_mltx-text_name = it_matmaster-matnr.

APPEND it_mltx.

**-- Quantities

  • it_uom-gross_wt = it_matmaster-brgew.

  • it_uom-alt_unit = 'KG'.

  • it_uom-alt_unit_iso = 'KG'.

  • it_uom-unit_of_wt = it_matmaster-gewei.

  • APPEND it_uom.

  • it_uomx-gross_wt = c_selected.

  • it_uomx-alt_unit = 'KG'.

  • it_uomx-alt_unit_iso = 'KG'.

  • it_uomx-unit_of_wt = c_selected.

  • APPEND it_uomx.

**-- Units

  • it_mean-unit = 'KD3'.

  • APPEND it_mean.

*-- Call the BAPI

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = bapimathead

clientdata = bapi_mara

clientdatax = bapi_marax

plantdata = bapi_marc

plantdatax = bapi_marcx

storagelocationdata = bapi_mard

storagelocationdatax = bapi_mardx

valuationdata = bapi_mbew

valuationdatax = bapi_mbewx

salesdata = bapi_mvke

salesdatax = bapi_mvkex

IMPORTING

return = it_return

TABLES

materialdescription = it_materialdesc.

  • unitsofmeasure = it_uom

  • unitsofmeasurex = it_uomx.

  • internationalartnos = it_mean.

IF it_return-type = 'E' OR

it_return-type = 'A'.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

*-- Write the log

WRITE:/(10) lv_counter CENTERED COLOR 6,

12 it_matmaster-matnr COLOR 6,

34 it_return-message COLOR 6.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = c_selected

IMPORTING

return = it_return1.

*-- Write the log

WRITE:/(10) lv_counter CENTERED COLOR 5,

12 it_matmaster-matnr COLOR 5,

34 it_return-message COLOR 5.

ENDIF.

ENDLOOP.