09-08-2011 10:42 AM
Hi all,
I have a requirement to upload data from excel 2007 to sap. I tried the function module TEXT_CONVERT_XLS_TO_SAP, but it is failing. I have not used ALSM_EXCEL_TO_INTERNAL_TABLE as it has limitation of uploading data upto 10K records only. So, can anyone please provide a function module name that can support both excel 2007 and 2003 formats. Thank you in advance.
Regards,
N.M.S.M.Krishna
09-08-2011 11:00 AM
Hi,
You can try using like this
*--Uploading xls sheet
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_locin "Path
has_field_separator = 'X'
TABLES
data_tab = li_text_data
lv_file = p_locin.
*--Converting the xls to readable format
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_tab_raw_data = li_text_data
i_filename = lv_file
TABLES
i_tab_converted_data = i_locfile.
09-08-2011 1:53 PM
Hi Kiran,
Check as Vinraj suggested. If there is any issue then post.
Regards,
Madhu.
09-08-2011 3:04 PM
Hi
You can try using the FM KCD_EXCEL_OLE_TO_INT_CONVERT which uploads both Excel 2007 and Excel 2003.
http://wiki.sdn.sap.com/wiki/display/Snippets/ExcelUploadAlternativefunctionmodule+KCD_EXCEL_OLE_TO_INT_CONVERT
Shiva
09-09-2011 8:05 AM
Hi Krishna
I tried, This is working for Excel 2007.
DATA:
t_raw TYPE truxs_t_text_data.
PARAMETERS:
p_infile TYPE localfile OBLIGATORY. " File path
Load EXCEL file into internal table
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = t_raw " work table
i_filename = p_infile
TABLES
i_tab_converted_data = t_upload[]
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.
Regards,
Surya.
09-09-2011 3:29 PM
Hi Vanraj,
I tried by implementing your code snippet method. It was going to runtime error in FM GUI_UPLOAD.
But anyway, the FM TEXT_CONVERT_XLS_TO_SAP is working for me. Probably there might be a system specific some problem when previously I tried. Only thing is, when I provide the .xlsx file and press execute, an message window pops up with message,
The file you are now trying to open, '~SAP{CCA4CB7F-3C79-425C-ADAC-665BBA7A55AC}.tmp ', is in a different format than specified by the file extension. Verify that the file is not corrupt and is from a trusted source before opening the file.Do you want to open the file now?
YES NO
if i press on YES, it is uploading. if i click on NO, its stopping.
Ultimately is working. But my doubt is, is there a way to avoid this error message from displaying and upload data directly when executed?
Regards,
N.M.S.M.Krishna.
Edited by: N.M.S.M.Krishna on Sep 9, 2011 4:34 PM
09-03-2014 2:54 PM
Hi Krish,
This post is old but I just want to let you know that this could be resolved if you use the following SAP note:
1517552 - The file you are trying to open is in a different format...
Regards,
Carlos