此BAPI用于创建和修改物料,这里做了一个更新产品条码的范例
效果:
代码:
REPORT ZMMRTEST. DATA : ls_headdata LIKE bapimathead, lt_marm LIKE TABLE OF bapi_marm, lt_marmx LIKE TABLE OF bapi_marmx, lt_mean LIKE TABLE OF bapi_mean, ls_marm LIKE bapi_marm, ls_marmx LIKE bapi_marmx, ls_mean LIKE bapi_mean, ls_return LIKE bapiret2. ls_headdata-material_long = ls_headdata-material_external = 'EQ-100991-01-DE'. ls_headdata-ind_sector = 'M'. "產業別1-零售業 ls_headdata-matl_type = 'FERT'. "物料類型 ls_headdata-basic_view = 'X'. "基本資料檢視 ls_marm-alt_unit = 'EA'. ls_marm-ean_upc = '091878806221'. "產品條碼 ls_marm-ean_cat = 'UC'. "EAN類別 APPEND ls_marm TO lt_marm. ls_marmx-alt_unit = 'EA'. ls_marmx-ean_upc = 'X'. "產品條碼 ls_marmx-ean_cat = 'X'. "EAN類別 APPEND ls_marmx TO lt_marmx. CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA' EXPORTING headdata = ls_headdata IMPORTING return = ls_return TABLES unitsofmeasure = lt_marm unitsofmeasurex = lt_marmx. IF ls_return-type = 'E'. ROLLBACK WORK. ELSE. COMMIT WORK AND WAIT. ENDIF. cl_demo_output=>write( ls_return ). cl_demo_output=>display( ).