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: 

Error while file upload by FM "TEXT_CONVERT_XLS_TO_SAP"

Former Member
0 Kudos

HI all,

I need to upload an excel file to SAP system ,for the same i am using the FM TEXT_CONVERT_XLS_TO_SAP in following way.

TYPE-POOLS truxs.

DATA: lv_raw TYPE truxs_t_text_data.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

i_field_seperator = 'X' "is an .xls file

i_line_header = 'X' "has a header line

i_tab_raw_data = lv_raw

i_filename = v_file

TABLES

i_tab_converted_data = etd_itab

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

But i get sy-subrc = 1,which is conversion error.

The structure of the etd_itab is same as the excel file ,even the field names are same ,still i wonder why should the conversion error been encountered .

Am i missing on anything ?

Please comment.

Thanks,

Swati

1 ACCEPTED SOLUTION

former_member206439
Contributor

And one more thing if header exits then

i_tab_converted_data = etd_itab[].

try this

7 REPLIES 7

Former Member
0 Kudos

Hi,

Try to give the parameters like

i_field_seperator = ' '

i_line_header = ' '

Hope this helps.

Vikki

0 Kudos

HI Vikki,

It does not work by giving the space for the two parameters.

i_field_seperator = ' '

i_line_header = ' ' .

Is there anything else?

0 Kudos

Could you send me a sample data that you hav in excel sheet..

and also the structure of your internal table

0 Kudos

Hi ,

The structure of my excel file and the data is as follows

PO_NO Item Div Material Vend PO_Date PO Bal.

4400000001 10 C SVC-PART-01 BCCS 2006.10.29 12

4500000348 10 L BA41-00383A BCCS 0

-


Following is the program flow

TYPES : BEGIN OF gt_etd ,

po_no LIKE ekpo-ebeln,

item LIKE ekpo-ebelp,

div LIKE mara-spart,

material LIKE kondd-smatn,

vend LIKE ekko-lifnr,

po_date LIKE ekpo-aedat,

po_bal LIKE ekpo-menge,

  • delivery_date LIKE ekes-eindt,

END OF gt_etd.

DATA: etd_itab TYPE STANDARD TABLE OF gt_etd WITH HEADER LINE.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pcfile.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = '.xls'

def_path = 'C:\'

mask = ',.txt;.xls,.txt;.xls.'

mode = 'O'

title = ' '

IMPORTING

filename = pcfile

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

IF pcfile IS INITIAL.

WRITE: / 'SELECT UPLOAD FILE !'.

ELSE.

MOVE pcfile TO v_file.

ENDIF.

*ETD file upload

CLEAR: lv_raw, etd_itab[].

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

i_field_seperator = ' ' "is an .xls file

i_line_header = ' ' "has a header line

i_tab_raw_data = lv_raw

i_filename = v_file

TABLES

i_tab_converted_data = etd_itab

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

Please advice ,why am i getting conversion error.

Thanks a lot .

Former Member
0 Kudos

Hai swati....

pass the necessary parameters only.

iam sending a sample prg. check it out.

it will be helpful for U to solve the problem.

type-pools : truxs.

types : begin of ty_tab,

f1(10) type c,

f2(10) type c,

f3(10) type c,

end of ty_tab.

data : wa_tab type ty_tab,

lt_tab like standard table of wa_tab.

data : i_tab_raw_data type truxs_t_text_data.

data : fnam type ibipparms-path.

parameter : p_fnam type rlgrap-filename.

*****

at selection-screen on value-request for p_fnam.

call function 'F4_FILENAME'

importing

file_name = fnam

.

p_fnam = fnam.

*****

start-of-selection.

call function 'TEXT_CONVERT_XLS_TO_SAP'

exporting

i_tab_raw_data = i_tab_raw_data

i_filename = fnam

tables

i_tab_converted_data = lt_tab.

loop at lt_tab into wa_tab.

write 😕 wa_tab-f1, wa_tab-f2.

endloop.

former_member206439
Contributor
0 Kudos

Hi

the file type must be

file_in TYPE rlgrap-filename

former_member206439
Contributor

And one more thing if header exits then

i_tab_converted_data = etd_itab[].

try this