10-10-2007 12:19 PM
How can we upload a singe Excel file with abap program.
i had used GUI_UPLOAD.
The code which i m using is given below,but it is not giving the proper output.
The excel sheet has 6 columns and around 3000 rows to upload.
can any one correct my code.
REPORT Z_UPLOAD .
types: begin of tdat,
fld1(20) type c,
fld2(20) type c,
fld3(10) type c,
fld4(10) type c,
fld5 type d,
fld6 type i,
end of tdat.
data: idat type standard table of tdat initial size 0,
wa_dat type tdat.
data: file_str type string.
parameters: p_file type localfile.
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.
file_str = p_file.
call function 'GUI_UPLOAD'
exporting
filename = file_str
has_field_separator = 'X'
tables
data_tab = idat
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.
loop at idat into wa_dat.
write 😕 wa_dat-fld1.
endloop.
10-10-2007 12:32 PM
Hi
Use FM ALSM_EXCEL_TO_INTERNAL_TABLE
TYPES:
BEGIN OF ty_upload,
field1 TYPE c length 12,
field2 TYPE c length 12,
field3 TYPE c length 12,
END OF ty_upload.
DATA it_upload TYPE STANDARD TABLE OF ty_upload WITH DEFAULT KEY.
DATA wa_upload TYPE ty_upload.
DATA itab TYPE STANDARD TABLE OF alsmex_tabline WITH DEFAULT KEY.
FIELD-SYMBOLS: <wa> type alsmex_tabline.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = filename
i_begin_col = 1
i_begin_row = 1
i_end_col = 3
i_end_row = 65535
TABLES
intern = itab.
LOOP AT itab ASSIGNING <wa>.
CASE <wa>-col.
WHEN '0001'.
wa_upload-field1 = <wa>-value.
WHEN '0002'.
wa_upload-field2 = <wa>-value.
WHEN '0003'.
wa_upload-field3 = <wa>-value.
ENDCASE.
APPEND wa_upload TO it_upload.
CLEAR wa_upload.
ENDLOOP.
<b>Reward if usefull</b>
10-10-2007 12:30 PM
hi,
Use this functional module : ALSM_EXCEL_TO_INTERNAL_TABLE
Regards,
Madhu
10-10-2007 12:32 PM
Hi
Use FM ALSM_EXCEL_TO_INTERNAL_TABLE
TYPES:
BEGIN OF ty_upload,
field1 TYPE c length 12,
field2 TYPE c length 12,
field3 TYPE c length 12,
END OF ty_upload.
DATA it_upload TYPE STANDARD TABLE OF ty_upload WITH DEFAULT KEY.
DATA wa_upload TYPE ty_upload.
DATA itab TYPE STANDARD TABLE OF alsmex_tabline WITH DEFAULT KEY.
FIELD-SYMBOLS: <wa> type alsmex_tabline.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = filename
i_begin_col = 1
i_begin_row = 1
i_end_col = 3
i_end_row = 65535
TABLES
intern = itab.
LOOP AT itab ASSIGNING <wa>.
CASE <wa>-col.
WHEN '0001'.
wa_upload-field1 = <wa>-value.
WHEN '0002'.
wa_upload-field2 = <wa>-value.
WHEN '0003'.
wa_upload-field3 = <wa>-value.
ENDCASE.
APPEND wa_upload TO it_upload.
CLEAR wa_upload.
ENDLOOP.
<b>Reward if usefull</b>
10-10-2007 1:17 PM
10-10-2007 1:20 PM
ok
is it your problem solved or not
if solved then click on solved rediobutton