‎2007 May 22 1:42 PM
Hi all,
l like to upload data from local file.
My question is how to upload data from .xls file using function 'GUI_UPLOAD', and then transfert that data into local internal table.
Bob
‎2007 May 22 1:44 PM
Hello,
You can get filetype by extracting last three characters of filename. It can be .xls,.txt,etc..
If it is of '.txt',use Function module 'GUI_UPLOAD'.
If it is of '.xls',use Function module 'ALSM_EXCEL_TO_INTERNAL_TABLE'.
Regards,
Deepu.K
‎2007 May 22 1:44 PM
Hello,
You can get filetype by extracting last three characters of filename. It can be .xls,.txt,etc..
If it is of '.txt',use Function module 'GUI_UPLOAD'.
If it is of '.xls',use Function module 'ALSM_EXCEL_TO_INTERNAL_TABLE'.
Regards,
Deepu.K
‎2007 May 22 1:45 PM
Have you tried using the function call ALSM_EXCEL_TO_INTERNAL_TABLE ?
~Suresh
‎2007 May 22 1:45 PM
Hi,
If u want to upload from Excel then use this FM "'ALSM_EXCEL_TO_INTERNAL_TABLE'"
Hope this info helps.
Regards,
Kumar.
‎2007 May 22 1:47 PM
hI,
To Upload the excel file FM 'ALSM_EXCEL_TO_INTERNAL_TABLE'
BElow is the sample code.
report ztest.
types: begin of ttab ,
fld1(30) type c,
fld2(30) type c,
fld3(30) type c,
fld4(30) type c,
fld5(30) type c,
end of ttab.
data: itab type table of ttab with header line.
selection-screen skip 1.
parameters: p_file type localfile default
'C:\test.txt'.
selection-screen skip 1.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
clear itab. refresh itab.
perform upload_data.
loop at itab.
write:/ itab-fld1, itab-fld2, itab-fld3, itab-fld4, itab-fld5.
endloop.
************************************************************************
Upload_Data
************************************************************************
form upload_data.
data: file type rlgrap-filename.
data: xcel type table of alsmex_tabline with header line.
file = p_file.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '200'
i_end_row = '10000'
tables
intern = xcel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
loop at xcel.
case xcel-col.
when '0001'.
itab-fld1 = xcel-value.
when '0002'.
itab-fld2 = xcel-value.
when '0003'.
itab-fld3 = xcel-value.
when '0004'.
itab-fld4 = xcel-value.
when '0005'.
itab-fld5 = xcel-value.
endcase.
at end of row.
append itab.
clear itab.
endat.
endloop.
endform.
Reward Points if it is Useful.
Thanks,
Manjunath MS
‎2007 May 22 1:48 PM
Hi,
Please use ws_upload instead.
See the following link for additional details:
http://goldenink.com/abap/ws_upload.html
Reward if helpful!
- John
‎2007 May 22 1:48 PM