Both Kcd_excel_ole_to_int_convert and alsm_excel_to_internal_table are common functions in ABAP to read EXCEL files. The biggest difference between the two is that the maximum length of the cell value in Kcd_excel_ole_to_int_convert is limited to 32,alsm_excel_to_internal_table the maximum length of the cell value is 50.
1.Kcd_excel_ole_to_int_convert usage is as follows:
* * Read into the inner table from a known file name
* Call FUNCTION ' Kcd_excel_ole_to_int_convert '
* Exporting
* FILENAME = P_file
* I_begin_col = 1
* I_begin_row = 1
* I_end_col =
* I_end_row = 65535
* TABLES
* INTERN = i_excel[]
* EXCEPTIONS
* inconsistent_parameters = 1
* Upload_ole = 2
* OTHERS = 3.
*
* IF SY-SUBRC <> 0.
* MESSAGE ' Open file error, please check the file, make sure to close the file! ' TYPE ' E '.
* STOP.
* ENDIF.
*
* REFRESH ITAB.
* CLEAR ITAB.
*
*
* LOOP at I_excel.
* Case I_excel-col.
* when ' 001 '.
* WRITE i_excel-value to ITAB-MATNR.
* when ' 002 '.
* WRITE i_excel-value to ITAB-MAKTX.
*
* endcase.
* at END of ROW.
* APPEND ITAB.
* CLEAR ITAB.
* ENDAT.
* Endloop.
2. Alsm_excel_to_internal_table usage is as follows:
FIELD-symbols: <fs>.
REFRESHItexcel.
CLEARItexcel.
PagerFUNCTION' alsm_excel_to_internal_table '
Exporting
FILENAME = P_file
I_begin_col =1
I_begin_row =1
I_end_col =255
I_end_row =65536
TABLES
INTERN = itexcel[].
REFRESHITAB.
CLEARITAB.
LOOP atItexcel.
on Change ofItexcel-row.
IFSy-tabixNE1.
APPENDITAB.
CLEARITAB.
ENDIF.
Endon.
ASSIGNCOMPONENTItexcel-col ofSTRUCTUREITAB to<fs>.The dynamic method passes the value to the corresponding inner table
<fs> = itexcel-value.
Endloop.
APPENDITAB."Don't forget to append the last piece into the inner table .
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Read the EXCEL table's two functions alsm_excel_to_internal_table, Kcd_excel_ole_to_int_convert