Hi All,
I am going to explain how do we
upload the local
excel files to the
one Drive or
share folder through the Report.
Some one would be confused to upload the files into the share folder. so I am trying to explain some better way.
Step1: We can see the
Excel file in the local file folder as below.
I.e.. This PC > Desktop > Emp1
Step2: Before going to write the program we need to get the
one drive or
Share Folder path.
Note: Please observe there is
no File in this OneDrive folder
I.e.. OneDrive > MOURI Tech > CHEP
Copy the
URL in notepad
Give the file name you would like to save in One Drive.
"C:\Users\sreeramg\OneDrive - MOURI Tech\CHEP\
Employee1.CSV"
Step3: Write the
Report for save file in OneDrive:
REPORT zupload_share_point8
.
** Data Declarations
DATA: gv_filename
TYPE string
,
lt_data_tab
TYPE TABLE OF x255
,
lv_bin_size
TYPE i,
lv_file
TYPE string
.
** Parameters
PARAMETERS : gv_name TYPE localfile.
** Selection screen value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR gv_name
.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name
= gv_name
.
IF sy
-subrc <>
0.
* Implement suitable error handling here
ENDIF.
START-OF-SELECTION.
gv_filename
= gv_name
.
** upload the file data from desktop/localfile
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename
= gv_filename
filetype
= 'BIN'
IMPORTING
filelength
= lv_bin_size
TABLES
data_tab
= lt_data_tab .
lv_file
= 'C:\Users\sreeramg\OneDrive - MOURI Tech\CHEP\Employee1.csv'.
*** Download or save the file in to the share folder
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename
= lv_file
filetype
= 'BIN'
write_field_separator
= 'X'
TABLES
data_tab
= lt_data_tab
* fieldnames = it_header
EXCEPTIONS
file_write_error
= 1
no_batch
= 2
gui_refuse_filetransfer
= 3
invalid_type
= 4
no_authority
= 5
unknown_error
= 6
header_not_allowed
= 7
separator_not_allowed
= 8
filesize_not_allowed
= 9
header_too_long
= 10
dp_error_create
= 11
dp_error_send
= 12
dp_error_write
= 13
unknown_dp_error
= 14
access_denied
= 15
dp_out_of_memory
= 16
disk_full
= 17
dp_timeout
= 18
file_not_found
= 19
dataprovider_exception
= 20
control_flush_error
= 21
OTHERS = 22
.
IF sy
-subrc <>
0.
* Implement suitable error handling here
ENDIF.
IF sy
-subrc
= 0.
WRITE: /
'Successfully uploaded to One Drive'.
ENDIF.
Step4:
Execute the Report and select the Excel file which you like to upload.
Execute again
Successfully uploaded the file in OneDrive.
We can check the OneDrive folder and we can see the saved Excel file.
Hope This log will be helpful..!
Thanks & Regards,
Sreeram G.