TABLES:bapimathead,
bapi_makt,
bapi_mara,
bapi_marax.
DATA:BEGIN OF itab OCCURS 0,
material TYPE bapimathead-material,
ind_sector(20),
matl_type TYPE bapimathead-matl_type,
matl_group TYPE bapi_mara-matl_group,
langu TYPE bapi_makt-langu,
matl_desc TYPE bapi_makt-matl_desc,
END OF itab,
it_return LIKE bapiret2,
it_bapi LIKE bapi_makt OCCURS 0 WITH HEADER LINE.
PARAMETERS:p_file TYPE localfile.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_f4help.
START-OF-SELECTION.
PERFORM upload_file_itab.
PERFORM call_bapi.
*&---------------------------------------------------------------------*
*& Form get_f4help
*&---------------------------------------------------------------------*
FORM get_f4help .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
ENDFORM. " get_f4help
*&---------------------------------------------------------------------*
*& Form upload_file_itab
*&---------------------------------------------------------------------*
FORM upload_file_itab .
DATA:v_file TYPE string.
MOVE p_file TO v_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab.
ENDFORM. " upload_file_itab
*&---------------------------------------------------------------------*
*& Form call_bapi
*&---------------------------------------------------------------------*
FORM call_bapi .
LOOP AT itab.
bapimathead-material = itab-material.
bapimathead-ind_sector = itab-ind_sector.
bapimathead-matl_type = itab-matl_type.
bapimathead-basic_view = 'X'.
bapi_mara-matl_group = itab-matl_group.
bapi_mara-base_uom = 'KGS'.
bapi_marax-matl_group = 'X'.
bapi_marax-base_uom = 'X'.
it_bapi-langu = itab-langu.
it_bapi-langu_iso = 'EN'.
it_bapi-matl_desc = itab-matl_desc.
APPEND it_bapi.
CLEAR it_bapi.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = bapimathead
clientdata = bapi_mara
clientdatax = bapi_marax
IMPORTING
return = it_return
TABLES
materialdescription = it_bapi.
IF it_return-type NE 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
* IMPORTING
* RETURN =
.
WRITE : / 'Material created:',bapimathead-material.
ELSE.
WRITE:/ it_return-message.
ENDIF.
ENDLOOP.
ENDFORM. "
Flat File:
000000000011111113 M ROH 001 EN Test1
000000000011111114 M ROH 001 EN Test2