标签:表数据 xls path abs ram data src request name
tYPE-POOLS: truxs.
DATA: BEGIN OF build,
name(10) TYPE c,
age(3) TYPE c,
sex(2) TYPE c,
spa TYPE p DECIMALS 2,
END OF build.
DATA tabbuild LIKE TABLE OF build WITH HEADER LINE.
DATA tabs LIKE tabbuild.
DATA: il_raw TYPE truxs_t_text_data. "可用可不用
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
PARAMETERS: p_carr LIKE RLGRAP-FILENAME OBLIGATORY . "DEFAULT ‘D:\数据模板\替换BOM组件.XLS‘
SELECTION-SCREEN END OF BLOCK bk1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_carr . "请务必把此代码写进来
CALL FUNCTION ‘WS_FILENAME_GET‘ "获取excel文件
EXPORTING
* DEF_FILENAME = ‘ ‘
def_path = ‘C:\‘
"Structure of MASK: ,<text>,<FILTERGROUP>.
"Structure of FILTERGROUP: <filter>;<filter>*
mask = ‘,Excel File,*.xls;*.xlsx;*.txt.‘
title = ‘Window Title:请选择文件‘
"弹出框的模式 S -- 用来保存文件 O -- 用来打开文件
MODE = ‘S‘
IMPORTING
filename = p_carr
* RC =
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3"如果用户取消了对话框
SELECTION_ERROR = 4
OTHERS = 5.
START-OF-SELECTION.
CALL FUNCTION ‘TEXT_CONVERT_XLS_TO_SAP‘ "将excel文件中的内容传入内表
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER = ‘X‘
i_tab_raw_data = il_raw
i_filename = p_carr
TABLES
i_tab_converted_data = tabbuild
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT tabbuild INTO tabs. "输出内表数据
WRITE: / tabs-name,tabs-age,tabs-sex, tabs-spa.
ENDLOOP.
标签:表数据 xls path abs ram data src request name
原文地址:https://www.cnblogs.com/abapweb/p/11630968.html