09-10-2008 4:46 AM
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
09-10-2008 4:52 AM
09-10-2008 5:58 AM
09-10-2008 6:00 AM
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