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: 

how to use FM " TEXT_CONVERT_XLS_TO_SAP "

Former Member
0 Kudos

hi experts, i have got a few FM that are used for uploading data of Excel into SAP. But i am unable to

understand what value i need to pass to the parameters of listed Function Module.

Name of the Function Modules are :---

1) ALSM_EXCEL_TO_INTERNAL_TABLE

2) TEXT_CONVERT_XLS_TO_SAP

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Function module 'TEXT_CONVERT_XLS_TO_SAP' is used to read data XSL Spreadsheet data from desktop computer and converts to the internal table.

For below example:

l_file: "C:\Reports.xls".

g_t_term = Target internal table to upload

l_truxs = raw interal table.


  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      i_tab_raw_data       = l_truxs
      i_filename           = l_file
    TABLES
      i_tab_converted_data = g_t_term.

Do not use Function modeule ALSM_EXCEL_TO_INTERNAL_TABLE as its not released by SAP and doesn't work with latest versions of Windows (Vista).

7 REPLIES 7

Former Member
0 Kudos

TYPE-POOLS: truxs.

'TEXT_CONVERT_XLS_TO_SAP' FM is used to get data from an excel sheet and upload it into an internal table

DATA: it_raw TYPE truxs_t_text_data.

PARAMETERS: p_file TYPE rlgrap-filename.

"Upload the file

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

i_line_header = 'X'

i_tab_raw_data = it_raw

i_filename = p_file

TABLES

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

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

exporting

filename = p_file

i_begin_col = '1'

i_begin_row = '2' "Do not require headings

i_end_col = '19'

i_end_row = '30'

tables

intern = itab

exceptions

inconsistent_parameters = 1

upload_ole = 2

others = 3.

if sy-subrc <> 0.

message e010(zz) with text-001. "Problem uploading Excel Spreadsheet

endif.

0 Kudos

Hi Nitwick.

Thanks for helping me in how to read Excel data into itab. this is working good with text data but

still i am getting problem while uploading numeric value from excel.

it reads text but not numeric value.

plz guide me with an example.

0 Kudos

I think thats the way it works, it treats the data in file as text.

0 Kudos

Use CHAR_NUMC_CONVERSION after retreiving the data.

0 Kudos

Use Function Module CHAR_NUMC_CONVERSION after retreiving the data.

For Example :

&----


*& Report Y_TEMP *

*& *

&----


*& *

*& *

&----


REPORT Y_TEMP .

types: begin of ty_tab,

key(5) type c,

conv_field(10) type c,

end of ty_tab.

Data: lt_tab type standard table of ty_tab, " Retrieved Table from Excel

ls_tab type ty_tab.

types: begin of ty_tabconv,

key(5) type c,

conv_field type i,

end of ty_tabconv.

Data: lt_tabconv type standard table of ty_tabconv, " Converted Table

ls_tabconv type ty_tabconv.

ls_tab-key = '1'.

ls_tab-conv_field = '1000'.

append ls_tab to lt_tab.

ls_tab-key = '2'.

ls_tab-conv_field = '2222'.

append ls_tab to lt_tab.

data num_conv type i.

loop at lt_tab into ls_tab.

CALL FUNCTION 'CHAR_NUMC_CONVERSION'

EXPORTING

INPUT = ls_tab-conv_field

IMPORTING

NUMCSTR = num_conv.

ls_tabconv-conv_field = num_conv.

modify table lt_tabconv from ls_tabconv transporting conv_field.

write 😕 ls_tab-key, ls_tab-conv_field.

skip 1.

write 😕 ls_tabconv-key, ls_tabconv-conv_field.

endloop.

Former Member
0 Kudos

Function module 'TEXT_CONVERT_XLS_TO_SAP' is used to read data XSL Spreadsheet data from desktop computer and converts to the internal table.

For below example:

l_file: "C:\Reports.xls".

g_t_term = Target internal table to upload

l_truxs = raw interal table.


  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      i_tab_raw_data       = l_truxs
      i_filename           = l_file
    TABLES
      i_tab_converted_data = g_t_term.

Do not use Function modeule ALSM_EXCEL_TO_INTERNAL_TABLE as its not released by SAP and doesn't work with latest versions of Windows (Vista).

0 Kudos

Hi Sheetal.

Thanks for helping me in how to read Excel data into itab. this is working good with text data but

still i am getting problem while uploading numeric value from excel.

it reads text but not numeric value.

plz guide me with some example.