2015 Oct 13 7:17 AM
Hi,
I am trying to download the values from excel to internal table but it is throwing error.
EXCEL FILE CANNOT OPEN THE FILE NAME.XLSX BECAUSE FILE FORMAT OR FILE EXTENSION IS NOT VALID.
First data is in excel sheet,after debugging excel file also not opening and data also not downloaded into internal table.
Anyone suggest please?
2015 Oct 13 7:23 AM
Hello Nitya,
Can you please specify how you are reading the excel file. Using which FM ??
Regards,
Deepan.
2015 Oct 13 7:25 AM
Hi thanks for your reply,
Am using gui_download fm..
file name; name.xlsx
2015 Oct 13 7:30 AM
Hello Nithya,
I think GUI_DOWNLOAD can support file format .XLS and not XLSX. Could you please check with .XLS extension
Cheers,
Varun
2015 Oct 13 7:31 AM
Hello,
GUI_DOWNLOAD FM is used to download the data in the Internal table into Local file (For eg: xlsx).
In case if you need to get the data from Excel into internal table, you have to use the FM GUI_UPLOAD.
While calling this FM, please specify the path of the xlsx file.
Hope it helps.
Regards,
Deepan Swaminathan.
2015 Oct 13 7:45 AM
hi,
Yeah now am able to getting datas in itab,but it is unconverted format,Is there any function module for
convert to sap internal table??
2015 Oct 13 8:46 AM
2015 Oct 13 8:54 AM
To upload from excel file
use the following function
DATA: l_filename TYPE rlgrap-filename. "string.
DATA: it_raw TYPE truxs_t_text_data.
l_filename = p_file.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file "l_filename
TABLES
i_tab_converted_data = gt_file "ACTUAL DATA
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
2015 Oct 13 9:55 AM
Hello Nithya,
Use below FM, it will convert excel into internal table format.
CALL
FUNCTION
'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = FILEPATH
i_begin_col = 1
i_begin_row = 3
i_end_col = 5
i_end_row = 9
tables
intern = IT_TAB
*
EXCEPTIONS
*
INCONSISTENT_PARAMETERS = 1
*
UPLOAD_OLE = 2
*
OTHERS
= 3
.
IF
sy-subrc <> 0.
*
MESSAGE
ID SY-MSGID
TYPE
SY-MSGTY NUMBER SY-MSGNO
*
WITH
SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF
.
Thanks,
Sujeet
2024 Jul 03 10:42 AM
To download xlsx via GUI_Download, you can translate your itab into Binary.
To have a header, you need to set your itab fields into chars or string, then apend it at first row.
CLEAR lv_len.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = lo_salv
CHANGING
t_table = <lt_output>.
CALL METHOD lo_salv->to_xml
EXPORTING
xml_type = if_salv_bs_xml=>c_type_xlsx
RECEIVING
xml = lv_xml.
CATCH cx_salv_error INTO lo_ex.
lv_error = lo_ex->get_text( ).
BREAK-POINT.
ENDTRY.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xml
IMPORTING
output_length = lv_len
TABLES
binary_tab = lt_bin.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lv_len
filename = p_file_str
filetype = 'BIN'
TABLES
data_tab = lt_bin
fieldnames = lt_field.
Hope it help.