Posted: Sat Sep 15, 2007 9:12 pm Post subject: PC file: upload to or download from application server
Code:
report z.
types: t_file(255) type c,
t_inf(65535) type c,
t_it type t_inf occurs 0.
************************************************************************
parameters:
pcfile like rlgrap-filename default 'c:\temp\' obligatory lower case,
unixfile type t_file default '/tmp/' obligatory lower case,
pctounix radiobutton group x,
unixtopc radiobutton group x.
************************************************************************
data: it_file type t_it with header line,
w_msg(100).
************************************************************************
at selection-screen on value-request for pcfile.
call function 'WS_FILENAME_GET'
exporting mask = ',*.*,*.*.'
importing filename = pcfile
exceptions others = 1.
if sy-subrc <> 0.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
************************************************************************
form read_file.
*--- open UNIX file
open dataset unixfile for input in text mode message w_msg.
if sy-subrc ne 0.
write: / 'Cannot open for reading:', unixfile, w_msg.
exit.
endif.
*--- read UNIX file
do.
read dataset unixfile into it_file.
if sy-subrc = 0. append it_file.
else. exit.
endif.
enddo.
*--- close UNIX file
close dataset unixfile.
endform.
************************************************************************
form write_file.
*--- open UNIX file
open dataset unixfile for output in text mode message w_msg.
if sy-subrc ne 0.
write: / 'Cannot open for writing:', unixfile, w_msg.
exit.
endif.
*--- write UNIX file
loop at it_file.
transfer it_file to unixfile.
endloop.
*--- close UNIX file
close dataset unixfile.
endform.
************************************************************************
form ws_upload.
call function 'WS_UPLOAD'
exporting
filename = pcfile
filetype = 'ASC'
tables
data_tab = it_file
exceptions
others = 1.
if sy-subrc <> 0.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform.
************************************************************************
form ws_download.
call function 'WS_DOWNLOAD'
exporting
filename = pcfile
filetype = 'ASC'
tables
data_tab = it_file
exceptions
others = 1.
if sy-subrc <> 0.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform.
************************************************************************
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.