Hola,
puedes utilizar la siguiente bapi: BAPI_MATERIAL_SAVEDATA
Te copio el código de un programa muy sencillo, lo que hace es cargar desde un fichero una serie de materiales con los campos de las unidades de materiales.
Este es el programa.
REPORT zcarga_conversiones_modif NO STANDARD PAGE HEADING
LINE-SIZE 130.
TABLES: marm.
*********************************************************************
**************** Declaracion de tablas ************************
*-------> definicion de tablas
*-------> tablas internas
DATA: BEGIN OF ti_mater OCCURS 0,
matnr(18), " material
umrem(6), " cantidad en U.M. Alternativa
meinh(3), " Unidad de medida alternativa
umrez(6), " CAntidad en U.M. Base
ean11(18), " Codigo EAN
numtp(2), " Tipo EAN
laeng(17),
breit(17),
hoehe(17),
meabm(3),
volum(17),
voleh(3),
brgew(17),
gewei(3),
azsub(10),
mesub(3),
END OF ti_mater.
************************ declaracion de variables *******************
DATA: bapi_head LIKE bapimathead,
bapi_return LIKE bapiret2.
DATA: BEGIN OF unitsofmeasure OCCURS 100.
INCLUDE STRUCTURE bapi_marm.
DATA: END OF unitsofmeasure.
DATA: BEGIN OF unitsofmeasurex OCCURS 100.
INCLUDE STRUCTURE bapi_marmx.
DATA: END OF unitsofmeasurex.
*********************************************************************
**************** Pantalla de seleccion inicial *********************
*********************************************************************
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK blk_1 WITH FRAME TITLE text-001.
*
**-----------> fichero
PARAMETERS: p_fich LIKE rlgrap-filename DEFAULT 'C:\UNIDADES.TXT'.
SELECTION-SCREEN END OF BLOCK blk_1.
**************** Programa Principal *********************************
*********************************************************************
START-OF-SELECTION.
* Carga de datos desde el fichero
PERFORM cargar_datos_de_excel.
* Modificamos las unidades de medida.
PERFORM bapi_material_savedata.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form CARGAR_DATOS_DE_EXCEL
*&---------------------------------------------------------------------*
FORM cargar_datos_de_excel.
* cargamos los datos del fichero de excel guardado en formato de
* texto con tabulaciones
CLEAR: ti_mater.
REFRESH: ti_mater.
CALL FUNCTION 'UPLOAD'
EXPORTING
* CODEPAGE = 'IBM '
filename = p_fich
filetype = 'DAT'
TABLES
data_tab = ti_mater
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
ENDFORM. " CARGAR_DATOS_DE_EXCEL
*&---------------------------------------------------------------------*
*& Form BAPI_MATERIAL_SAVEDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM bapi_material_savedata .
LOOP AT ti_mater.
CLEAR: unitsofmeasure, unitsofmeasurex,
unitsofmeasure[], unitsofmeasurex[].
* Cabecera
bapi_head-material = ti_mater-matnr.
* Unidades de Medida
unitsofmeasure-alt_unit = ti_mater-meinh.
unitsofmeasurex-alt_unit = ti_mater-meinh.
unitsofmeasure-alt_unit_iso = ti_mater-meinh.
unitsofmeasurex-alt_unit_iso = ti_mater-meinh.
unitsofmeasure-numerator = ti_mater-umrez.
unitsofmeasurex-numerator = 'X'.
unitsofmeasure-denominatr = ti_mater-umrem.
unitsofmeasurex-denominatr = 'X'.
APPEND unitsofmeasure.
APPEND unitsofmeasurex.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = bapi_head
* clientdata = bapi_mara1
* clientdatax = bapi_marax
* plantdata = bapi_marc1
* plantdatax = bapi_marcx
* FORECASTPARAMETERS =
* FORECASTPARAMETERSX =
* PLANNINGDATA =
* PLANNINGDATAX =
* STORAGELOCATIONDATA =
* STORAGELOCATIONDATAX =
* valuationdata = bapi_mbew1
* valuationdatax = bapi_mbewx
* WAREHOUSENUMBERDATA =
* WAREHOUSENUMBERDATAX =
* SALESDATA = BAPI_MVKE1
* SALESDATAX = BAPI_MVKEX
* STORAGETYPEDATA =
* STORAGETYPEDATAX =
IMPORTING
return = bapi_return
TABLES
* materialdescription = int_makt
unitsofmeasure = unitsofmeasure
unitsofmeasurex = unitsofmeasurex
* INTERNATIONALARTNOS =
* MATERIALLONGTEXT =
* TAXCLASSIFICATIONS =
* RETURNMESSAGES =
* PRTDATA =
* PRTDATAX =
* EXTENSIONIN =
* EXTENSIONINX =
.
IF bapi_return-type = 'E'.
WRITE:/ 'Error Message: ', bapi_return-number, bapi_return-id.
ENDIF.
ENDLOOP.
ENDFORM. " BAPI_MATERIAL_SAVEDATA
Un saludo y espero que te sirva de algo.