09-15-2008 1:15 PM
Hello everybody,
I am trying to find out a function which can load an excel sheet to a SAP internal table.
Having a look in the forum, I have already found interesting answers but on our SAP platform (SCM), the following function modules don't exist:
- ALSM_EXCEL_TO_INTERNAL_TABLE
- KCD_EXCEL_OLE_TO_INT_CONVERT
- TEXT_CONVERT_XLS_TO_SAP
I also tried to use function module GUI_UPLOAD, but it does not seem to work with a *.xls file.
It seems to be ok only with a *.csv file, but I would prefer a solution for a *.xls file.
But maybe I don't use it properly???
Do you have any (other) idea?
Regards,
Rudy
09-15-2008 1:46 PM
Hi Rudy,
Use the following program as a reference which helps you to transfer excel file data to internal table. I used function module TEXT_CONVERT_XLS_TO_SAP for this.
REPORT ZEXCEL_UPLOAD.
TYPE-POOLS truxs.
TABLES : zscarr.
Selection screen
PARAMETER p_file TYPE rlgrap-filename DEFAULT 'C:\TEST.xls'.
TYPES:
BEGIN OF t_tab,
carrid TYPE zscarr-carrid,
seats TYPE zscarr-total_seats,
END OF t_tab.DATA :
t_upload TYPE STANDARD TABLE OF t_tab,
wa_upload TYPE t_tab,
it_type TYPE truxs_t_text_data.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
START-OF-SELECTION.
Uploading the data in the file into internal table
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
i_tab_raw_data = it_type
i_filename = p_file
TABLES
i_tab_converted_data = t_upload[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Thanks,
Naveen Kumar.
09-15-2008 1:48 PM
09-15-2008 1:51 PM