06-11-2009 12:56 PM
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
06-11-2009 2:46 PM
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).
06-11-2009 1:09 PM
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.
06-12-2009 11:56 AM
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.
06-12-2009 8:23 PM
I think thats the way it works, it treats the data in file as text.
06-14-2009 9:39 AM
06-14-2009 10:05 AM
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.
06-11-2009 2:46 PM
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).
06-12-2009 11:55 AM
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.