Skip to Content
Technical Articles
Author's profile photo Roshan K

Excel Data to Internal table using ALSM_EXCEL_TO_INTERNAL_TABLE(obsolete) without additional code.


WARNING: This post is intended to Excel upload FM which is now obsolete. Follow this, only if you are working on older systems to maintain the code where you’ve already used ‘ALSM_EXCEL_TO_INTERNAL_TABLE’.

Also this post will help you grasp concept of Field symbols with below application. 

This blog post will help you avoid extraneous code every time you create Excel upload program by creating a simple Interface and a structure.

For ALSM_EXCEL_TO_INTERNAL_TABLE, explicitly we need to write code to transfer output of this FM into internal table of desired format. For this we have to map column number of FM output with columns of required internal table using

Refer below example.

filename            p_file
i_begin_col        1
i_begin_row      1
i_end_col          9
i_end_row        65536
intern                  t_file
inconsistent_parameters 1
upload_ole                      2
OTHERS                        3.

Output is in below format.

Further based on column number, work area is filled using CASE-ENDCASE and then Appending work area into required internal table in AT END OF ROW block.


CASE (column)

when 1. wa_itab-col1 = value

when 2. wa_itab-col2 = value.

….and so on depending upon number of columns in Excel



APPEND wa_itab to itab.




In order to avoid extraneous code when it comes to uploading Excel File with huge number of columns, create a FM with below code. Once you create Z FM, for every Excel File you’ll just need to create a structure in SE11  and you’re good to go.

Pass Desktop File path, Structure name in p_File and STR as input Parameters respectively.

First Create Structure in SE11 similar to the Excel File format.

FUNCTION zxls_into_it_2.
*”*”Local interface:
DATA:new_line    TYPE REF TO data,
new_line2 TYPE REF TO data,
li_fieldcat TYPE lvc_t_fcat,
dy_table    TYPE REF TO data,
t_file      TYPE STANDARD TABLE OF alsmex_tabline,
wa_file     TYPE alsmex_tabline,
v_col       TYPE i,
begin_row   TYPE i.

********This will provide Fields in Row format of Structure created(which should be similar to Excel Format).
i_structure_name       str
ct_fieldcat                  li_fieldcat
inconsistent_interface 1
program_error            2
OTHERS                    3.
IF sysubrc EQ 0.

********This will create internal table which will have fields as per the Excel Format.
CALL METHOD cl_alv_table_create=>create_dynamic_table
it_fieldcatalog           li_fieldcat
i_length_in_byte          ‘X’
ep_table                  dy_table
generate_subpool_dir_full 1
OTHERS                    2.
IF sysubrc EQ 0.
ASSIGN dy_table->TO <dy_table>.

******V_col will hold the number of Columns inside Excel File which is later passed to ALSM_EXCEL_TO_INTERNAL_TABLE’ .

DESCRIBE TABLE li_fieldcat LINES v_col.

******Logic to skip Header
IF header ‘X’.
begin_row 2.
begin_row 1.

******Core FM which will provide excel data in  t_file with row/coumn/value format

filename              p_file
i_begin_col          1
i_begin_row        begin_row
i_end_col            v_col
i_end_row            65536
intern                  t_file
inconsistent_parameters 1
upload_ole              2
OTHERS                  3.

IF sysubrc EQ 0.
LOOP AT t_file INTO wa_file.

******This Block will create new area to store column wise data.<wa_temp> acts as a work area which is completely blank at start of new row
AT NEW row.
CREATE DATA new_line2 LIKE LINE OF <dy_table>.
ASSIGN new_line2->TO <wa_temp>.

*******for every iteration, wa_file-col will have increment till number of columns in Excel file and then reset to 1 when there’s new row i.e row = 1. (Refer example at end of blog)

ASSIGN COMPONENT wa_filecol OF STRUCTURE <wa_temp> TO <fs_current_field>.
IF sysubrc EQ 0.

<fs_current_field> wa_filevalue.
UNASSIGN <fs_current_field>.

*****Finally once all Columns are processed and new row is about to start, append the workarea into Internal table

AT END OF row.
APPEND <wa_temp> TO it_xls_data.
UNASSIGN <fs_current_field>.
UNASSIGN <wa_temp>.



Explanation with example:

Now simply create a structure in SE11, define Internal table of that type in report and call above FM and pass the structure name and file path and its done.



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Sandra Rossi
      Sandra Rossi

      There are many drawbacks with ALSM_EXCEL_TO_INTERNAL_TABLE:

      First, the limits explained in the SAP note 933420 - ALSM_EXCEL_TO_INTERNAL_TABLE:

      • It's not released for customers
      • It's only available in a R/3 or S/4 system (i.e. doesn't work on all other ABAP-based softwares)
      • The output structure is limited to 9999 rows and columns
      • The output structure is limited to 50 characters per cell.

      Second, the limits because it's based on OLE:

      • It's very slow (especially because it doesn't use Desktop Office Integration)
      • It cannot run in background (or any process not connected to a SAP GUI)

      Workaround ---> use abap2xlsx (it's been discussed a lot in the forum)

      Author's profile photo Paul Hardy
      Paul Hardy

      It would not be a normal week on the SAP Community if at least one person did not post a blog with some code they have come up with to do the same thing as ABAP2XLSX.

      Author's profile photo Peter Inotai
      Peter Inotai


      (yet another ABAP to XLS blog) 🙂

      Author's profile photo 小刚 哥哥
      小刚 哥哥

      very good , very helpfull for us.

      Author's profile photo 春 余
      春 余

      This is very useful, but in a call in "do while", the task manager will have multiple Excel.exe processes with the number of calls.I tried using "CALL METHOD OF workbook 'CLOSE' " before the "FREE object", but it didn't work. How can I kill the Excel.exe process?