Application Development and Automation 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: 
Read only

Incorrect result using the function ALSM_EXCEL_TO_INTERNAL_TABLE

Former Member
0 Likes
658

I have used the function ALSM_EXCEL_TO_INTERNAL_TABLE to load a Excel sheet on an internal table and the function returns the following result:

Row Col Value

0001 0001 902000100 A601 K 627542130 021 AGARDUN ZMAS 673 EU

0002 0001 902000101 A602 K 627542131 022 AGARDUN ZMAS 695 EU

0003 0001 902000102 A603 K 627542132 023 AGARDUN ZMAS 717 EU

0004 0001 902000103 A604 k 627542133 024 AGARDUN ZMAS 739 EU

0005 0001 902000104 A605 k 627542134 025 AGARDUN ZMAS 761 EU

0006 0001 902000105 A606 W 627542135 026 AGARDUN ZMAS 783 EU

0007 0001 902000106 A607 W 627542136 027 AGARDUN ZMAS 805 EU

0008 0001 902000107 A608 W 627542137 028 AGARDUN ZMAS 827 EU

0009 0001 902000108 A609 K 627542138 029 AGARDUN ZMAS 849 EU

0010 0001 902000109 A610 k 627542139 030 AGARDUN ZMAS 871 EU

0011 0001 902000110 A611 O 627542140 031 AGARDUN ZMAS 893 EU

That is to say, the excel sheet has nine columns, and the function thinks that only has 1 column.

I have checked the function with the same file in other computers, and the result has been the correct one, that is to say, the function returns the value of the column in its corresponding column:

Row Col Value

0001 0001 902000100

0001 0002 A601

0001 0003 K

0001 0004 627542130

0001 0005 021

0001 0006 AGARDUN

0001 0007 ZMAS

0001 0008 673

0001 0009 EU

0002 0001 902000101

0002 0002 A602

0002 0003 K

0002 0004 627542131

0002 0005 022

0002 0006 AGARDUN

0002 0007 ZMAS

0002 0008 717

0002 0009 EU

:

:

Can you help me?

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
591

Hi please use the following FM

This will solve your problem

<b>TEXT_CONVERT_XLS_TO_SAP</b>

code

TYPE-POOLS : truxs.

DATA : ws_rawdata TYPE truxs_t_text_data.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

I_FIELD_SEPERATOR = 'X'

i_tab_raw_data = ws_rawdata

i_filename = filename

TABLES

i_tab_converted_data = (your internal table)

Message was edited by: Dominic Pappaly

4 REPLIES 4
Read only

Former Member
0 Likes
591

Hi Garduño,

1. U want to upload data from EXCEL

into internal table.

2. and u are using ALSM_EXCEL_TO_INTERNAL_TABLE.

3. But We cannot do this direclty !

*----

-


For uploading purpose :

6. There are TWO options.

a) either save the excel to TAB Delimited file,

and use GUI_UPLOAD to upload the data in internal table.

b) use FM for excel purpose.

7. a) is easy and recommended

8. b) there is a FM for it,

but we have to apply some more logic

bcos the FM uploads data of excel

in the intenal table,

CELL BY CELL

9. afTER THAT , we have to convert this cell by cell data,

into our format of internal table.

10. use this code (just copy paste in new program)

(it is tried wit T001 structure data)

(it will AUTOMATICALLY based upon the

fields of internal table,

convert data from cell by cell,

to that of internal table fields)

REPORT abc.

*----

-


DATA : ex LIKE TABLE OF alsmex_tabline WITH HEADER LINE.

DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.

DATA : cmp LIKE TABLE OF rstrucinfo WITH HEADER LINE.

DATA : col TYPE i.

DATA : col1 TYPE i.

FIELD-SYMBOLS : .

DATA : fldname(50) TYPE c.

*----

-


CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = 'd:def.xls'

i_begin_col = 1

i_begin_row = 1

i_end_col = 100

i_end_row = 100

TABLES

intern = ex

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

BREAK-POINT.

*----

-


CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

program = sy-repid

fieldname = 'T001'

TABLES

components = cmp.

*----

-


LOOP AT ex.

AT NEW row.

IF sy-tabix = ex-value.

ENDLOOP.

BREAK-POINT.

regards,

amit m.

Read only

Former Member
0 Likes
592

Hi please use the following FM

This will solve your problem

<b>TEXT_CONVERT_XLS_TO_SAP</b>

code

TYPE-POOLS : truxs.

DATA : ws_rawdata TYPE truxs_t_text_data.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

I_FIELD_SEPERATOR = 'X'

i_tab_raw_data = ws_rawdata

i_filename = filename

TABLES

i_tab_converted_data = (your internal table)

Message was edited by: Dominic Pappaly

Read only

0 Likes
591

Thanks.

Regards.

Angel.

Read only

0 Likes
591

Hi,

I had the same problem and it was solved reinstalling the SAP Front End on the especific computer.

I think that it was a setting problem, because when the System executes the method CLIPBOARD_IMPORT from class CL_GUI_FRONTEND_SERVICES, the character ASC 009 (Horizontal Tab - "%_HORIZONTAL_TAB") is not recognized.

Regards.

Anderson.