ABAP使用函数把excel读入ABAP内表
ABAP使用函数把excel读入ABAP内表
使用函数的简单调用
REPORT YTEST00T.
data : BEGIN OF iexcel OCCURS 0. "定义excel内表
INCLUDE STRUCTURE alsmex_tabline.
data: END OF iexcel.
*输出文件名参数,在运行界面输入路径及excel文件名称,例如:D:\test
PARAMETERS: fn1 LIKE rlgrap-filename MEMORY ID M01.
*从已知文件名读入到内表限100列1000行。
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = fn1
i_begin_col = 1
i_begin_row = 1
i_end_col = 100
i_end_row = 1000
tables
intern = iexcel
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
.
IF sy-subrc <> 0.
WRITE:/ 'read file error!',fn1.
else.
"循环读取内表并打印,行末换行,打印每个字段限制20位
loop at iexcel.
write iexcel-value(20).
at END OF row.
WRITE:/.
endat.
ENDLOOP.
ENDIF.

浙公网安备 33010602011771号