12-02-2008 12:08 PM
Hi All,
I want to get the data from an excel file using the FM 'TEXT_CONVERT_XLS_TO_SAP'.
I have writtten the code as follows:
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = pa_file " File path
TABLES
i_tab_converted_data = i_final " Final internal Table
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
I am getting the values in the fianl internal table(i_final) but only for the items. I also want to get the header values.
Can you please suggest me how to get the header values.
Thanks & Regards,
Vivek
12-02-2008 2:26 PM
Hi,
I hope this will work out:
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = T_UPLOAD[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
Thanks & Regards,
Krishna...
12-02-2008 12:11 PM
Hi,
Try passing parameter I_LINE_HEADER = ' '.
Note : To add to what ajay said if the header data does't match the data type of the internal table you will get a short dump.
Regards
Edited by: Rajvansh Ravi on Dec 2, 2008 1:16 PM
08-22-2012 12:25 PM
if ur excel sheet has heading then pass it 'X' & if there is no heading then just comment it.
it will work fine.
12-02-2008 12:12 PM
Hi in this method this FM uploads only items not the column names.
use the following FM for ur requirement.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = P_file
i_begin_col = '0001'
i_begin_row = rowbgn1
i_end_col = '0028'
i_end_row = rowend1
TABLES
intern = it_exload
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
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,
Ajay
12-02-2008 12:12 PM
hi,
can u please tell me the structure of ur excel sheet, what do u mean by header values...is header values in seperate file ....
Rgds.,
subash
12-02-2008 12:14 PM
try that like this
i_line_header = space.
it may work. some times it will go to dump test it.
Regards,
Ajay
12-02-2008 12:18 PM
Hi ,
I have tried passing SPACE but its not working.
Also i cant use any other FM i have to do this with this FM only.
Thanks & Regards,
Vivek
12-02-2008 12:21 PM
12-02-2008 12:24 PM
have u done like this ?
TYPE-POOLS: truxs.
DATA: it_raw TYPE truxs_t_text_data.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file
TABLES
i_tab_converted_data = i_XCEL[]
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.
12-02-2008 12:31 PM
Yes i have tried like this only . But its not working.
The sy-subrc is changing to 1.
12-02-2008 12:38 PM
i_line_header = space. has to work. if u give 'X' it will neglect the first row. If you give space it will upload that also.
that has worked for me.
Could you plz try it again by activating whole program. ?
Regards,
Ajay
12-02-2008 12:35 PM
hi,
in the function module make
i_line_header = gc_x.
and also make sure that when u r executing the program see that the excel file is not opened.. close it
before u execute the program.
It should work definitely...there is nothing wrong in the coding..
Rgds.,
subash
12-02-2008 2:26 PM
Hi,
I hope this will work out:
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = T_UPLOAD[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
Thanks & Regards,
Krishna...
01-30-2009 4:52 AM