Skip to Content
0
Aug 03, 2016 at 04:32 AM

some fields are not updated using BAPI_MATERIAL_SAVEDATA

1641 Views

Hi, we've been trying to use the BAPI_MATERIAL_SAVEDATA in creating new materials. But there are some fields that are not being updated to MARA and MARC:

total shelf life - MARA-MHDHB

min rem shelf life - MARA-MHDRZ

minimum lot. size - MARC-BSTMI

Here's the part of the code that uses BAPI..

bapi_mara-matl_group = gs_data-matkl.

bapi_mara-division = gs_data-spart.

bapi_mara-net_weight = gs_data-ntgew.

bapi_mara-unit_of_wt = gs_data-gewei.

bapi_mara-base_uom = gs_data-meins.

bapi_mara-po_unit = gs_data-bstme.

bapi_mara-net_weight = gs_data-ntgew.

bapi_mara-unit_of_wt = gs_data-gewei.

bapi_mara-base_uom = gs_data-meins.

bapi_mara-matl_group = gs_data-matkl.

bapi_mara-division = gs_data-spart.

bapi_mara-batch_mgmt = gs_data-xchpf.

bapi_mara-minremlife = gs_data-mhdrz.

bapi_mara-shelf_life = gs_data-mhdhb.

bapi_mara-pur_status = gs_data-mstae.

bapi_mara-sal_status = gs_data-mstav.

bapi_mara-pvalidfrom = gs_data-mstde.

bapi_mara-svalidfrom = gs_data-mstdv.

bapi_mara-trans_grp = gs_data-tragr.

PERFORM: chk_flds USING bapi_mara-matl_group CHANGING bapi_marax-matl_group,

chk_flds USING bapi_mara-division CHANGING bapi_marax-division,

chk_flds USING bapi_mara-net_weight CHANGING bapi_marax-net_weight,

chk_flds USING bapi_mara-unit_of_wt CHANGING bapi_marax-unit_of_wt,

chk_flds USING bapi_mara-base_uom CHANGING bapi_marax-base_uom,

chk_flds USING bapi_mara-po_unit CHANGING bapi_marax-po_unit,

chk_flds USING bapi_mara-net_weight CHANGING bapi_marax-net_weight,

chk_flds USING bapi_mara-unit_of_wt CHANGING bapi_marax-unit_of_wt,

chk_flds USING bapi_mara-base_uom CHANGING bapi_marax-base_uom,

chk_flds USING bapi_mara-matl_group CHANGING bapi_marax-matl_group,

chk_flds USING bapi_mara-division CHANGING bapi_marax-division,

chk_flds USING bapi_mara-batch_mgmt CHANGING bapi_marax-batch_mgmt,

chk_flds USING bapi_mara-minremlife CHANGING bapi_marax-minremlife,

chk_flds USING bapi_mara-shelf_life CHANGING bapi_marax-shelf_life,

chk_flds USING bapi_mara-pur_status CHANGING bapi_marax-pur_status,

chk_flds USING bapi_mara-sal_status CHANGING bapi_marax-sal_status,

chk_flds USING bapi_mara-pvalidfrom CHANGING bapi_marax-pvalidfrom,

chk_flds USING bapi_mara-svalidfrom CHANGING bapi_marax-svalidfrom,

chk_flds USING bapi_mara-trans_grp CHANGING bapi_marax-trans_grp.

bapi_marc-plant = '1100'.

bapi_marc-availcheck = '02'.

bapi_marc-batch_mgmt = gs_data-xchpf.

bapi_marc-minlotsize = gs_data-bstmi.

bapi_marcx-plant = '1100'.

PERFORM chk_flds USING bapi_marc-availcheck CHANGING bapi_marcx-availcheck.

PERFORM chk_flds USING bapi_marc-batch_mgmt CHANGING bapi_marcx-batch_mgmt.

PERFORM chk_flds USING bapi_marc-minlotsize CHANGING bapi_marcx-minlotsize.


* Call BAPI for material creation

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = bapimathead

clientdata = bapi_mara

clientdatax = bapi_marax

salesdata = bapi_mvke

salesdatax = bapi_mvkex

plantdata = bapi_marc

plantdatax = bapi_marcx

IMPORTING

return = it_return

TABLES

materialdescription = gt_makt

unitsofmeasure = gt_marm

unitsofmeasurex = gt_marmx

returnmessages = it_return

extensionin = it_extension

extensioninx = it_extensionx.

READ TABLE it_return WITH KEY type = 'S' id = 'M3' number = '800'.

IF sy-subrc EQ 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

MESSAGE i002 WITH gs_data-matnr

'you may proceed with the creation of Procurement Data'.

* Call Worflow

PERFORM call_workflow.

* Back to selection screen

SET SCREEN 0.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

lc_refnr = gs_data-matnr+8(10).

LOOP AT it_return ASSIGNING FIELD-SYMBOL(<lfs_return>) WHERE type = 'E'.

PERFORM add_msg USING lc_refnr

lc_bdcnr

<lfs_return>

CHANGING lt_buzei.

ENDLOOP.



Thanks for your help! 😊