實用且常用的FN:Upload Excel File Into Internal Table
呼叫主體:
FORM upload_data_to_it_excel .
CALL FUNCTION 'ZIEB_UPLOAD_EXCEL_INTO_ITAB'
EXPORTING
filename = p_path
i_begin_col = 1
i_begin_row = 4
i_end_col = 17
i_end_row = 30000
TABLES
itab = it_excel.
ENDFORM. " UPLOAD_DATA_TO_IT_EXCEL
FN中的import項引數
FILENAME LIKE RLGRAP-FILENAME Local file for upload/download
I_BEGIN_COL TYPE I
I_BEGIN_ROW TYPE I
I_END_COL TYPE I
I_END_ROW TYPE I
FN中的TABLES項引數
ITAB
FN的Source code如下:
FUNCTION ZIEB_UPLOAD_EXCEL_INTO_ITAB .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(FILENAME) LIKE RLGRAP-FILENAME
*" REFERENCE(I_BEGIN_COL) TYPE I
*" REFERENCE(I_BEGIN_ROW) TYPE I
*" REFERENCE(I_END_COL) TYPE I
*" REFERENCE(I_END_ROW) TYPE I
*" TABLES
*" ITAB
*"----------------------------------------------------------------------
DATA : T_INTERN LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
DATA : L_TABIX LIKE SY-TABIX.
DATA : L_BEGCOL TYPE I,
L_BEGROW TYPE I,
L_ENDCOL TYPE I,
L_ENDROW TYPE I,
L_PATH LIKE RLGRAP-FILENAME.
MOVE : I_BEGIN_COL TO L_BEGCOL,
I_BEGIN_ROW TO L_BEGROW,
I_END_COL TO L_ENDCOL,
I_END_ROW TO L_ENDROW,
FILENAME TO L_PATH.
FIELD-SYMBOLS :
** upload excel file by standard function
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = L_PATH
I_BEGIN_COL = L_BEGCOL
I_BEGIN_ROW = L_BEGROW
I_END_COL = L_ENDCOL
I_END_ROW = L_ENDROW
TABLES
INTERN = T_INTERN
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
** 刪除第一筆
DELETE T_INTERN WHERE ROW = 1.
** standard function output internal table convert to...
** get the same row of value into one row split by 'TAB'
REFRESH : ITAB.
SORT T_INTERN BY ROW COL.
LOOP AT T_INTERN.
AT NEW ROW.
L_TABIX = SY-TABIX.
CLEAR : ITAB.
ENDAT.
AT END OF ROW.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE ITAB TO
IF SY-SUBRC = 0.
READ TABLE T_INTERN INDEX L_TABIX.
IF SY-SUBRC = 0 AND T_INTERN-COL = SY-INDEX.
ADD 1 TO L_TABIX.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
APPEND ITAB.
ENDAT.
ENDLOOP.
ENDFUNCTION.
大家可以試用一下,有問題可以在此提問.
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90072/viewspace-980298/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Upload excel file 到 INTERNAL TABLE 的方法Excel
- Upload & Download internal table to excelExcel
- 將Excel file上轉到Internal table的方法Excel
- FN_AUDIT - Name of security audit file
- File upload by JSP (轉)JS
- 採用Docker整合jquery-file-upload元件到WEB應用DockerjQuery元件Web
- Fckeditor PHP/ASP File Upload VulPHP
- html 5 drag and drop upload fileHTML
- 用Python完成Excel的常用操作PythonExcel
- angular-file-upload 在IE下使用的坑Angular
- excel快捷鍵大全常用 excel最新2022實用快捷鍵分享Excel
- ssis multiple table to one file
- FIneCMS /dayrui/libraries/Chart/ofc_upload_image.php Arbitrary File Upload VulUIPHP
- Salesforce LWC學習(二十七) File UploadSalesforce
- TableTools Export Excel前Table內容格式的轉換應用ExportExcel
- 如何做出酷炫且實用的視覺化大屏?Excel和PPT該淘汰了視覺化Excel
- HPUX Error 23 File table overflowUXError
- vue實現 可展開 且 可多選table 元件封裝Vue元件封裝
- 內表(internal table)和工作區(work area)的區別
- oracle query output in excel fileOracleExcel
- 這些技巧你知道嗎?macOS的Fn鍵實用秘訣Mac
- 上傳報錯:Upload Failed: Your upload has failed a virus scan. Please choose another file.AI
- 理解jquery的$.extend()、$.fn和$.fn.extend()jQuery
- 不用SE11建Structure傳Internal Table到Smartforms的方法StructORM
- Use Excel Pivot Table as a BI toolExcel
- 10個*級且實用的python庫!Python
- el-upload拍照上傳多個檔案報錯 ERR_UPLOAD_FILE_CHANGED問題
- Lua 列印table 實現型別python的repr用於table型別Python
- js常用的功能 table>tr>tdJS
- excel的常用統計功能Excel
- 百度翻譯 Excel TableExcel
- 常用的實用網站網站
- Python有哪些好用且實用的Web框架?PythonWeb框架
- 7種常見且實用的Python框架!Python框架
- 10款最新且超實用的開發框架框架
- 目前已知且常用的網站優化網站優化
- 尊重開源,且用且珍惜
- excel中最常用的30個函式 excel表格常用函式技巧大全Excel函式