09-11-2008 3:18 PM
Hi,
I am using 'TEXT_CONVERT_XLS_TO_SAP' fm to upload excel data. My excel has 73 lines. This fm is uploading 146 lines into my internal table. It is uploading the data twice.
Interesting part is that later on again I am using the same FM to upload the data and it works fine. That excel has 26 lines.I don't know why it is behaving like this.
here is my code:
DATA: BEGIN OF i_file_data OCCURS 0,
col1 TYPE text30,
col2 TYPE text30,
col3 TYPE text30,
col4 TYPE text30,
END OF i_file_data.
data: i_raw TYPE truxs_t_text_data.
FORM EXCEL_UPLOAD_MODCASE.
CLEAR I_FILE_DATA.
REFRESH I_FILE_DATA.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR = 'X'
I_LINE_HEADER =
I_TAB_RAW_DATA = i_raw
I_FILENAME = p_file2
TABLES
I_TAB_CONVERTED_DATA = i_file_data[]
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.
I am using excalty same code for second excel.
Any Suggestions are appreciated.
Regards,
DNP
09-11-2008 3:27 PM
Hi,
Try Changing the code Like
(I_FIELD_SEPERATOR = ) make it comment
I_LINE_HEADER = 'X'
Refer to the link.
http://www.sapdev.co.uk/file/file_upexcel.htm
Regards
Sumit Agarwal
09-11-2008 3:36 PM
Hi Sumit,
It does not work. Still it uploads twice the data in excel
02-26-2013 5:54 PM
This is problem with some XLS files, that TEXT_CONVERT_XLS_TO_SAP can't handle.
....
CALL METHOD l_iref_spreadsheet->insert_range
EXPORTING columns = l_columns
rows = l_rows
name = 'range1'
IMPORTING
retcode = l_retcode.
CALL METHOD l_iref_spreadsheet->get_ranges_names
IMPORTING ranges = l_range_list
retcode = l_retcode.
DELETE l_range_list WHERE name <> 'range1'.
....
Add delete line to solve this problem.
I believe this is already fixed on newer systems.
02-27-2013 3:31 AM
Hi,
Try my code as I have used this to upload excel files successfully:-
* Uploading the data in the file into internal table
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER = 'X'
i_tab_raw_data = it_type
i_filename = p_file
TABLES
i_tab_converted_data = t_upload[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
If this doesn't work , you can just debug the function module once with few test data in excel file.
Try this.
Thanks,
Bishwajit