Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Upload excel data into Internal table dynamically

Former Member
0 Kudos

Hi all,

I have a excel file, in this file there are fixed columns but I don't know, at run time, how many rows will come up.

Now I want to fetch the data from file to internal table, I used

GUI_UPLOAD and ALSM_EXCEL_TO_INTERNAL_TABLE.

But it is not working for me.

Please suggest how to get it.

Thanks

Sanket sethi

3 REPLIES 3

Former Member
0 Kudos

Hi,

Please check the below link

[]

Regards,

Surinder

Former Member
0 Kudos

Hi,

Use FM ALSM_EXCEL_TO_INTERNAL_TABLE.it should work

Former Member
0 Kudos

HI,

go through this code:

Upload data from Excel to internal table.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = p_pfile

i_begin_col = 1

i_begin_row = 2

i_end_col = 45

i_end_row = 8

TABLES

intern = it_excel

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. " IF sy-subrc 0

*Populate data to internal tables and structructures

SORT it_excel BY row col.

LOOP AT it_excel INTO ls_excel.

CASE ls_excel-col.

WHEN 1.

ls_data-doc_type = ls_excel-value.

WHEN 2.

ls_data-rec_no = ls_excel-value.

WHEN 3.

ls_data-doc_ver = ls_excel-value.

endcase.

endloop.

Hope it will help you

Thanks and Regards

Rahul Sharma