Read the EXCEL table's two functions alsm_excel_to_internal_table, Kcd_excel_ole_to_int_convert

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.