12-13-2004 11:09 AM
Hi SAp Gurus,
I need to upload data from Excel sheet(desktop)which has a field of length 80.
Fn module ALSM_EXCEL_TO_INTERNAL_TABLE has 'value' parm of lenght 50.
Gui_upload give file type mismatch....
upload/ws_upload give output data in junk format...
Any suggestions ?
Thanks in Advance
12-13-2004 11:23 AM
Convert excel file to <b>csv</b> format and use method <b>gui_upload</b> of class <b>cl_gui_frontend_services</b>.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = v_file
filetype = 'ASC'
has_field_separator = space
* HEADER_LENGTH = 1
IMPORTING
filelength = v_filelength
header = v_header
CHANGING
data_tab = i_file
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
.
IF sy-subrc <> 0 OR v_result IS INITIAL.
MESSAGE e015(zz) WITH 'File Invalid'.
ENDIF.
*** Splitting the contents of the file
LOOP AT i_file INTO wa_file.
SPLIT wa_file-data AT ',' INTO wa_data-werks
wa_data-maabc
wa_data-matnr
wa_data-validfrom
wa_data-validto
wa_data-weektype
wa_data-week1
wa_data-week2
wa_data-week3
wa_data-week4
wa_data-week5.
APPEND wa_data TO i_data.
ENDLOOP.
12-13-2004 11:44 AM
Convert to tab deliminated text.
use:
this
-
call function 'WS_UPLOAD'
exporting
filename = filename
filetype = 'DAT'
tables
data_tab = itab
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_table_width = 4
invalid_type = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
or use this
-
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
read_by_line = 'X'
DAT_MODE = 'X'
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = itab
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
.
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 it helps please give points.
12-16-2004 6:57 AM
Hi,
Im also using the same FM with the ff parameters:
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_pfname
i_begin_col = 1
i_begin_row = 1
i_end_col = 30 'upto N-col
i_end_row = 5000 'upto N-row
tables
intern = it_buffer
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
It should be straight forward and returns the Excel data into an Internal table.
Cheers,
Kelvin