Import Parameters:

Codes:
*&———————————————————————*
*& Report ZANIL
*&
*&———————————————————————*
*&
*&
*&———————————————————————*
report zanil.
* Job: uploading files(pdf, xlsx, txt, docx, png)
* from local pc to under AL11 directory..
* 1. Data
data p_upload type rlgrap–filename.
data ld_file type char255.
data filename type authb–filename .
data activity(20) value ‘WRITE’.
data lv_extension type char10.
data lv_val1 type string.
data lv_val2 type string.
data length like sy–tabix.
data lengthn like sy–tabix.
data gui_xstring type xstring.
data: begin of itab occurs 0,
field(256),
end of itab.
data lt_itab like table of itab.
data ls_itab like line of itab.
* 2. Parameters
parameters: p_fname type string
obligatory.
parameters: p_fnamc type authb–filename
default ‘e:\usr\sap\data’
obligatory.
start–of–selection.
* 3. Getting file source destination…
call function ‘/SAPDMC/LSM_F4_FRONTEND_FILE’
changing
pathfile = p_upload
exceptions
canceled_by_user = 1
system_error = 2
others = 3.
ld_file = p_upload.
if ld_file is initial.
message ‘No file selected!’ type ‘W’.
exit.
endif.
* 4. Getting file extension…
call function ‘TRINT_FILE_GET_EXTENSION’
exporting
filename = ld_file
importing
extension = lv_extension.
* 5. Uploading file under AL11
split ld_file at ‘.’ into lv_val1 lv_val2.
concatenate p_fnamc ‘\’ p_fname
‘.’ lv_extension into filename .
condense filename no–gaps.
lv_val1 = ld_file.
call function ‘GUI_UPLOAD’
exporting
filename = lv_val1
filetype = ‘BIN’
importing
filelength = length
tables
data_tab = lt_itab.
call function ‘SCMS_BINARY_TO_XSTRING’
exporting
input_length = length
importing
buffer = gui_xstring
tables
binary_tab = lt_itab
exceptions
failed = 1
others = 2.
open dataset filename
for output in binary mode.
loop at lt_itab into ls_itab.
transfer ls_itab–field to filename.
endloop.
close dataset filename.
write ‘file uploaded’.
