Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

problem with FM 'TEXT_CONVERT_XLS_TO_SAP'

Former Member

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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...

13 REPLIES 13

Former Member

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

0 Kudos

if ur excel sheet has heading then pass it 'X' & if there is no heading then just comment it.

it will work fine.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

try that like this

i_line_header = space.

it may work. some times it will go to dump test it.

Regards,

Ajay

Former Member
0 Kudos

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

0 Kudos

Hi

Try Like this

i_line_header = ' '

ranga

Former Member
0 Kudos

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.

Former Member
0 Kudos

Yes i have tried like this only . But its not working.

The sy-subrc is changing to 1.

0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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...

Former Member
0 Kudos

Thnak you all