GoodleAds

UPLOAD DATA FROM EXCEL TO INTERNAL TABLE

UPLOAD DATA FROM EXCEL TO INTERNAL TABLE:

The below program used to upload data from excel to internal table.

PROGRAM:

REPORT Z_EXCEL_TO_INTERNAL_TABLE.
TYPE-POOLS truxs.

* Selection screen
PARAMETER p_file TYPE rlgrap-filename"DEFAULT 'd:\temp\mytable.xls'.
TYPES:
BEGIN OF t_tab,
col1
(20TYPE c,
col2
(20TYPE c,
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.

END-OF-SELECTION.
* Uploading the data into the database table
LOOP AT T_UPLOAD INTO WA_UPLOAD.
WRITE:/ wa_upload-col1,
wa_upload
-col2.
ENDLOOP.

The excel file has the following details:




INPUT:



OUTPUT:



No comments:

Post a Comment