*--- 获取数据 DATA:LT_EXCEL TYPE TABLE OF ALSMEX_TABLINE, "具有 Excel 数据的表行 LV_INDEX TYPE I. "项目位置 *&---读取EXCEL到内表 CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' EXPORTING FILENAME = P_FILE I_BEGIN_COL = 2 I_BEGIN_ROW = 8 I_END_COL = 70 I_END_ROW = 1048576 TABLES INTERN = LT_EXCEL EXCEPTIONS INCONSISTENT_PARAMETERS = 1 UPLOAD_OLE = 2 OTHERS = 3. IF SY-SUBRC <> 0. MESSAGE 'EXCEL导入错误或文件路径错误' TYPE 'E'. ENDIF. *&--- 处理内表数据——>ALV内表 LOOP AT LT_EXCEL INTO DATA(LS_EXCEL). LV_INDEX = LS_EXCEL-COL. ASSIGN COMPONENT LV_INDEX OF STRUCTURE GS_ALV TO FIELD-SYMBOL(<F>). TRY. MOVE LS_EXCEL-VALUE TO <F>. CATCH CX_ROOT INTO DATA(CX). ENDTRY. AT END OF ROW. APPEND GS_ALV TO GT_ALV. CLEAR: GS_ALV. ENDAT. CLEAR LS_EXCEL. ENDLOOP.
标签:INDEX,GS,DATA,EXCEL,LS,ALV,SAP,上传 From: https://www.cnblogs.com/aqsyc/p/18354494