Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

TEXT_CONVERT_XLS_TO_SAP FM is throughing an error

Dear Friends,

I am uploading a xls file into internal table using TEXT_CONVERT_XLS_TO_SAP.

The file strusture is as below.

Row1: Customer City

Row 2: Customer City

Row2: 2000001 ABD

My requirement is to skip the first two row details, as they are just the field titles and i need not consider the first two row's.

I should pick the data from Third row onwards which is actual data.

I have to use this TEXT_CONVERT_XLS_TO_SAP FM only.

I have passed the

i_line_header = 'X'

in the function module it is deleting only one header hower to remove the other header what i have to do , because the FM is throughing an error conversion_failed.

Please help me .

.

Thanks

madhuri

Tags:
Former Member
Former Member replied

Hi,

You can do it as follows:

TYPE-POOLS:truxs.

DATA:li_tab_raw_data TYPE truxs_t_text_data.

DATA: BEGIN OF i_tab OCCURS 0,

fld1(6) TYPE c,

END OF i_tab.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

  • I_LINE_HEADER =

i_tab_raw_data = li_tab_raw_data

i_filename = 'C:\temp\test1_xls.xls'

TABLES

i_tab_converted_data = i_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.

LOOP AT i_tab.

IF sy-tabix EQ 1 OR sy-tabix EQ 2. "for first 2 rows

CONTINUE.

ENDIF.

ENDLOOP.

Or you can use following FM

ALSM_EXCEL_TO_INTERNAL_TABLE

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

exporting

filename = file

i_begin_col = 1

i_begin_row = 3 "to start from 3rd row

i_end_col = 2 "depends on # of col's

i_end_row = 65000

tables

intern = iexcel

exceptions

inconsistent_parameters = 1

upload_ole = 2

others = 3.

Thanks,

Vikram

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question