03-16-2011 9:14 PM
Hi All,
The Function Module 'TEXT_CONVERT_XLS_TO_SAP' opens a new empty excel sheet while uploading the file.
Please give me a solution for this. I do not want the empty excel file to be opened.
Thanks,
03-17-2011 4:30 AM
DATA:t_raw TYPE truxs_t_text_data.
PARAMETERS: p_file TYPE rlgrap-filename.
"Upload the file
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = t_raw
i_filename = p_file
TABLES
i_tab_converted_data = t_tab[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Please specify the path of the file p_file, contains the excel file which you want to upload contains data, or the active sheet contains the data.
03-17-2011 5:34 PM
Hi
I tried the same but its still opening an empty excel sheet.
Thanks
03-17-2011 3:55 PM
Hi,
Do like below. This will solve your problem.
*--Uploading xls sheet
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_locin "Path of file
has_field_separator = c_x
TABLES
data_tab = li_text_data
EXCEPTIONS
file_open_error = 1.
lv_file = p_locin.
*--Converting the xls to readable format
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = c_x
i_tab_raw_data = li_text_data
i_filename = lv_file
TABLES
i_tab_converted_data = i_locfile
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
03-17-2011 5:33 PM
Hi
Thank u for the post. I tried the same but its still opening an empty excel sheet while uploading. Could you please tell me what field separator have u given. I tried by giving SPACE as the Field Separator. I even tried commenting the Field Separator line. Both of them are opening an empty excel file. I am trying to upload a .xls, .xlsx, and .xlsb files.
Are there any other function modules to upload excel files to SAP.
Please see below my code and help me with the solution:
REPORT ZTEST3.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
data: file type string.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
col4(30) TYPE c,
col5(30) TYPE c,
col6(30) TYPE c,
col7(30) TYPE c,
col8(30) TYPE c,
col9(30) TYPE c,
col10(30) TYPE c,
col11(30) TYPE c,
col12(30) TYPE c,
col13(30) TYPE c,
col14(30) TYPE c,
col15(30) TYPE c,
col16(30) TYPE c,
col17(30) TYPE c,
col18(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab with header line.
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
*At selection screen.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
file = p_file.
*
************************************************************************
START-OF-SELECTION.
*--Uploading xls sheet
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file "Path of file
has_field_separator = SPACE
TABLES
data_tab = it_raw
EXCEPTIONS
file_open_error = 1.
lv_file = p_locin.
*--Converting the xls to readable format
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = SPACE
i_tab_raw_data = it_raw
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
Thanks
03-18-2011 5:23 AM
Hi,
You wanted to upload excel file into SAP, right.
Do not use 'TEXT_CONVERT_XLS_TO_SAP' then, use only GUI_UPLOAD, it will serve the purpose.
03-18-2011 8:01 AM
Please try this out
DATA: t_file TYPE STANDARD TABLE OF alsmex_tabline.
constants :c_begin_col TYPE i VALUE '1',
c_begin_row TYPE i VALUE '1',
c_end_col TYPE i VALUE '38',
c_end_row TYPE i VALUE '65535'.
DATA: lt_filetable TYPE filetable,
lx_filetable TYPE file_table,
lv_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = c_sel_text
default_extension = c_ext_exl
CHANGING
file_table = lt_filetable
rc = lv_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 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.
READ TABLE lt_filetable INTO lx_filetable INDEX 1.
CHECK sy-subrc EQ 0.
p_file = lx_filetable-filename.
CLEAR t_file[].
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = c_begin_col
i_begin_row = c_begin_row
i_end_col = c_end_col
i_end_row = c_end_row
TABLES
intern = t_file[]
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE s000 WITH text-002.
ENDIF.
Edited by: Rahul Babukuttan on Mar 18, 2011 9:03 AM