2008 Jan 31 8:26 AM
Can any one suggest me the ways with which we can transfer the file from application server to local file.
Even i want an F4 help suggesting the path of the local server where the file is to be stored.
Thanks in advance.
Can any one suggest me the ways with which we can transfer the file from application server to local file.
Even i want an F4 help suggesting the path of the local server where the file is to be stored.
Thanks in advance.
2008 Jan 31 8:29 AM
Hi Harshad,
It is designed for both upload and download and delete file from the application server.
Depends on the radio button check it will process ur request.
**----
types: begin of ty_rawdata,
LINE(1000) TYPE C,
end of ty_rawdata.
types: begin of ty_errors,
recordnumber type i,
errormessage(135) type c,
end of ty_errors.
data:
v_record_type(3),
v_runstatus,
f_errors(1) type c,
v_errors type ty_errors,
v_abort,
v_rawdata type ty_rawdata,
cnt_db_inserts type i,
v_linesread type i,
v_recordsread type i,
v_filename like rlgrap-filename,
v_infile like rlgrap-filename,
v_outfile like rlgrap-filename.
************************************************************************
INTERNAL TABLES *
************************************************************************
data:
TBL_RAWDATA TYPE TY_RAWDATA OCCURS 0 WITH HEADER LINE,
TBL_ERRORS TYPE TY_ERRORS OCCURS 0 WITH HEADER LINE.
parameters:
p_up radiobutton group r1,
p_dn radiobutton group r1,
p_del radiobutton group r1,
p_pfile like rlgrap-filename,
p_afile like rlgrap-filename default '/tmp/'.
************************************************************************
INITIALISATION *
************************************************************************
INITIALIZATION.
************************************************************************
AT SELECTION SCREEN *
************************************************************************
at selection-screen on value-request for p_pfile.
call function 'KD_GET_FILENAME_ON_F4'
exporting
mask = ',Text files, *.txt'
static = 'X'
changing
file_name = p_pfile.
************************************************************************
START OF SELECTION *
************************************************************************
start-of-selection.
if p_up = 'X'.
perform file_upload_presentation_srvr using p_pfile.
perform file_save using p_afile changing sy-subrc.
if sy-subrc = 0.
write / 'file uploaded'.
endif.
elseif p_dn = 'X'.
perform file_upload using p_afile.
perform file_save_presentation using p_pfile.
if sy-subrc = 0.
write / 'file downloaded'.
endif.
elseif p_del = 'X'.
perform file_delete using p_afile.
if sy-subrc = 0.
write / 'file deleted'.
endif.
endif.
&----
*& Form file_upload
&----
form file_upload using v_lfilename like v_filename.
data: v_msg(100).
Open the file for upload in text mode, and trap any messages.
open dataset v_lfilename for input in text mode message v_msg.
if sy-subrc ne 0.
Input file not found!
Process the error with an abort
message E006(ZSEC) with v_lfilename.
else.
The file has opened successfully. Upload every line in the file.
do.
Clear the work area, and read the record from the dataset.
clear v_rawdata.
read dataset v_lfilename into v_rawdata.
if sy-subrc ne 0.
The end of the file has been reached, so exit the 'DO' loop.
exit.
else.
v_linesread = v_linesread + 1.
endif.
Append the raw data line to the raw data internal table
append v_rawdata to tbl_rawdata.
enddo.
close dataset v_lfilename.
endif. "
endform. " file_upload
&----
*& Form file_upload_presentation_srvr
&----
form file_upload_presentation_srvr using v_lfilename like v_filename.
call function 'WS_UPLOAD'
exporting
CODEPAGE = ' '
filename = v_lfilename
FILETYPE = 'ASC'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
tables
data_tab = tbl_rawdata
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10
.
if sy-subrc 0 or v_lfilename is initial.
If no filename given, set the system variables to output message
if v_filename is initial.
message E005(ZSEC).
endif.
Input file not found!
else.
describe table tbl_rawdata lines v_linesread.
endif.
endform. " file_upload_presentation_srvr
&----
*& Form file_delete
&----
form file_delete using v_lfilename like v_filename.
Check program is not aborted
check v_abort is initial.
delete dataset v_lfilename.
if sy-subrc ne 0.
Append the message output to the error tracing table!
message E007(ZSEC) with v_lfilename.
endif.
endform. " file_delete
&----
*& Form file_save
&----
form file_save using v_lfilename like v_filename
changing v_lsubrc.
data: v_lmsg(100).
data: v_lsubrc2.
clear: v_lsubrc, v_lsubrc2.
Check program is not aborted
check v_abort is initial.
Open the file
open dataset v_lfilename for output in text mode message v_lmsg.
if sy-subrc ne 0.
Append the message output to the error tracing table!
v_lsubrc2 = 4.
message E006(ZSEC) with v_lfilename.
else.
clear v_rawdata.
loop at tbl_rawdata into v_rawdata.
transfer v_rawdata to v_lfilename.
if sy-subrc ne 0.
Error transferring data!
v_lsubrc2 = 4.
message E008(ZSEC) with v_lfilename.
endif.
clear v_rawdata.
endloop.
Close the file
close dataset v_lfilename.
if sy-subrc ne 0.
Error closing the dataset!
v_lsubrc2 = 4.
message E009(ZSEC) with v_lfilename.
endif.
endif.
v_lsubrc = v_lsubrc2.
endform. " file_save
&----
*& Form file_save_presentation
&----
text
-
-->P_P_PFILE text
-
form file_save_presentation using p_dnfile like rlgrap-filename.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME = P_DNFILE
FILETYPE = ' '
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = TBL_RAWDATA
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
OTHERS = 8.
endform. " file_save_presentation
Reward if found helpfull,
Cheers,
Chaitanya.
2008 Jan 31 2:52 PM
2008 Feb 01 11:22 AM
hai ,
plz Refer to the Function Module
Just Run The following FModule In SE37
C13z_app_to_front_end.
Then Give respective File Paths
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |