The document will give insights to two SAP standard function modules which can be used to upload / download files to / from application servers. There are few blogs on creating custom function modules to accomplish the task. Using the standard function modules will help in reducing this effort.
Data declaration:
Parameters: p_file type sapb-sappfad. “On presentation server
parameters : p_path type rlgrap-filename. “On Application serverAt selection-screen on value-request for p_path.
"Start to check current directory
call function '/SAPDMC/LSM_F4_SERVER_FILE'
exporting
filemask = ' '
importing
serverfile = p_path
exceptions
canceled_by_user = 1
others = 2.if sy-subrc <> 0.
p_path = p_path.
endif.
The above codes will popup the below screen for selecting the folder in application server:
a) Use ARCHIVEFILE_CLIENT_TO_SERVER function module to transfer file from presentation server to application server.
Code snippet:
call function 'ARCHIVFILE_CLIENT_TO_SERVER'
exporting
path = p_file
targetpath = p_path
exceptions
error_file = 1
others = 2.if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else .
message 'successfully transfered' type 'S'.
endif.
b) Use ARCHIVEFILE_SERVER_TO_CLIENT function module to transfer file from application server to presentation server.
Code snippet:
data : w_path type sapb-sappfad,
w_file type sapb-sappfad.parameters : p_path1 type rlgrap-filename.
parameters : p_file1 type rlgrap-filename.
move p_path1 to w_path.
move p_file1 to w_file.call function 'ARCHIVFILE_SERVER_TO_CLIENT'
exporting
path = w_path
targetpath = w_file
exceptions
error_file = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
message 'successfully transfered' type 'S' .
endif.
Request you to try out these function modules and get back on improvements, if any.
Cheers!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 |