Upload
program in ztable.
This
is Table
ID
|
NAME
|
EMPDES
|
EMPPHONE
|
||
53
|
Alex
|
9874563215
|
|||
54
|
Ponting
|
8745632103
|
*&---------------------------------------------------------------------*
*& Report ZSW_UPLOAD_TABLE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSW_UPLOAD_TABLE.
TYPE-POOLS truxs.
TABLES : ZEMP03.
PARAMETER p_file TYPE rlgrap-filename DEFAULT 'C:\Users\swadesh\Desktop\Book1_1.xlsx'.
TYPES:BEGIN OF t_tab,
EMPID TYPE ZEMP03-EMPID,
EMPNAME TYPE ZEMP03-EMPNAME,
EMPDES TYPE ZEMP03-EMPDES,
EMPPHONE TYPE ZEMP03-EMPPHONE,
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.
else.
MESSAGE 'Dada Upload sucessfull' TYPE 'I'.
endif.
END-OF-SELECTION.
* Uploading the data into the database table
LOOP AT T_UPLOAD INTO WA_UPLOAD.
ZEMP03-EMPID = WA_UPLOAD-EMPID.
ZEMP03-EMPNAME = WA_UPLOAD-EMPNAME.
ZEMP03-EMPDES = WA_UPLOAD-EMPDES.
ZEMP03-EMPPHONE = WA_UPLOAD-EMPPHONE.
MODIFY ZEMP03.
ENDLOOP.
*& Report ZSW_UPLOAD_TABLE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSW_UPLOAD_TABLE.
TYPE-POOLS truxs.
TABLES : ZEMP03.
PARAMETER p_file TYPE rlgrap-filename DEFAULT 'C:\Users\swadesh\Desktop\Book1_1.xlsx'.
TYPES:BEGIN OF t_tab,
EMPID TYPE ZEMP03-EMPID,
EMPNAME TYPE ZEMP03-EMPNAME,
EMPDES TYPE ZEMP03-EMPDES,
EMPPHONE TYPE ZEMP03-EMPPHONE,
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.
else.
MESSAGE 'Dada Upload sucessfull' TYPE 'I'.
endif.
END-OF-SELECTION.
* Uploading the data into the database table
LOOP AT T_UPLOAD INTO WA_UPLOAD.
ZEMP03-EMPID = WA_UPLOAD-EMPID.
ZEMP03-EMPNAME = WA_UPLOAD-EMPNAME.
ZEMP03-EMPDES = WA_UPLOAD-EMPDES.
ZEMP03-EMPPHONE = WA_UPLOAD-EMPPHONE.
MODIFY ZEMP03.
ENDLOOP.
After Updating Result.
No comments:
Post a Comment