DATA: gt_xldata LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE,
wa_xlstemp LIKE alsmex_tabline,
wa_tmp LIKE LINE OF gt_upload,"上传模板的字段结构
l_colindex TYPE i.
FIELD-SYMBOLS: <fs>.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_infile
i_begin_col = 2
i_begin_row = 4
i_end_col = 47
i_end_row = 10000
TABLES
intern = gt_xldata
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE e899(sd) WITH '上传文件错误,请重新上传!'.
ENDIF.
LOOP AT gt_xldata INTO wa_xlstemp.
l_colindex = wa_xlstemp-col.
"指定字段符号<fs>所要指向的字段
ASSIGN COMPONENT l_colindex OF STRUCTURE wa_tmp TO <fs>.
<fs> = wa_xlstemp-value.
*** 根据row值是否改变来判断是否读取到EXCEL另一行中的数据
AT END OF row.
APPEND wa_tmp TO gt_upload.
CLEAR wa_tmp.
ENDAT.
ENDLOOP.