07-13-2005 6:30 AM
How can i <b>Write File</b> on <i><b>Presentation Server</b></i>.
07-13-2005 6:32 AM
Hi,
U can check this link
http://www.sapdevelopment.co.uk/file/file_updown.htm
This method of file download with check uses the latest techniques
and achieves a very neat solution
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i.
Display save dialog window
CALL METHOD <b>cl_gui_frontend_services=>file_save_dialog</b>
EXPORTING
window_title = ' '
DEFAULT_EXTENSION = 'xls'
default_file_name = 'accountsdata'
INITIAL_DIRECTORY = 'c:\temp\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
Check user did not cancel request
CHECK ld_result EQ '0'.
CALL FUNCTION <b>'GUI_DOWNLOAD'</b>
EXPORTING
filename = ld_fullpath
filetype = 'ASC'
APPEND = 'X'
write_field_separator = 'X'
CONFIRM_OVERWRITE = 'X'
TABLES
data_tab = it_datatab[] "need to declare and populate
EXCEPTIONS
file_open_error = 1
file_write_error = 2
OTHERS = 3.
CALL FUNCTION <b>'WS_DOWNLOAD'</b>
EXPORTING
filename = p_pfile
filetype = 'ASC'
<b>filetype = 'DAT' (Tab delimited)</b>
IMPORTING
filesize = size "10/02/02
filelength = size "10/02/02
TABLES
data_tab = xls_tab
EXCEPTIONS
file_open_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = p_pfile
filetype = 'WK1'
IMPORTING
filesize = size
TABLES
data_tab = xls_tab
EXCEPTIONS
file_open_error = 1 "10/02/02
others = 2. "10/02/02
invalid_filesize = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
customer_error = 7.
IF sy-subrc NE 0.
WRITE: / 'Download file', p_pfile,
'has error with condition code', sy-subrc.
STOP.
ENDIF.
ENDIF.
Hope this helps.
Thanks & regards,
Judith.
Message was edited by: Judith Jessie Selvi
07-13-2005 6:32 AM
Hi,
U can check this link
http://www.sapdevelopment.co.uk/file/file_updown.htm
This method of file download with check uses the latest techniques
and achieves a very neat solution
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i.
Display save dialog window
CALL METHOD <b>cl_gui_frontend_services=>file_save_dialog</b>
EXPORTING
window_title = ' '
DEFAULT_EXTENSION = 'xls'
default_file_name = 'accountsdata'
INITIAL_DIRECTORY = 'c:\temp\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
Check user did not cancel request
CHECK ld_result EQ '0'.
CALL FUNCTION <b>'GUI_DOWNLOAD'</b>
EXPORTING
filename = ld_fullpath
filetype = 'ASC'
APPEND = 'X'
write_field_separator = 'X'
CONFIRM_OVERWRITE = 'X'
TABLES
data_tab = it_datatab[] "need to declare and populate
EXCEPTIONS
file_open_error = 1
file_write_error = 2
OTHERS = 3.
CALL FUNCTION <b>'WS_DOWNLOAD'</b>
EXPORTING
filename = p_pfile
filetype = 'ASC'
<b>filetype = 'DAT' (Tab delimited)</b>
IMPORTING
filesize = size "10/02/02
filelength = size "10/02/02
TABLES
data_tab = xls_tab
EXCEPTIONS
file_open_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = p_pfile
filetype = 'WK1'
IMPORTING
filesize = size
TABLES
data_tab = xls_tab
EXCEPTIONS
file_open_error = 1 "10/02/02
others = 2. "10/02/02
invalid_filesize = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
customer_error = 7.
IF sy-subrc NE 0.
WRITE: / 'Download file', p_pfile,
'has error with condition code', sy-subrc.
STOP.
ENDIF.
ENDIF.
Hope this helps.
Thanks & regards,
Judith.
Message was edited by: Judith Jessie Selvi
07-13-2005 6:35 AM
Hi,
You can use GUI_DOWNLOAD.WS_DOWNLOAD also you can use.But it is obsolete.
Ther following is taken from documentation.
File transfer from internal backend table to file on the presentation server.
Storage of SAP data in a file in the file system of the presentation server. A format conversion is possible. The functions are similar to the module WS_DOWNLOAD, however the data provider is used for the download and not GMUX.
Example
CALL FUNCTION 'GUI_DOWNLOAD'
exporting
bin_filesize = 500
filetype = 'BIN'
filename = 'C:\DOWNLOAD.BIN'
tables
data_tab = itab.
loads 500 from the internal table itab into the file 'C:\DOWNLOAD.BIN' on the frontend PC. The transferred data is not converted.
CALL FUNCTION 'GUI_DOWNLOAD'
exporting
filetype = 'ASC'
filename = 'C:\DOWNLOAD.TXT'
tables
data_tab = itab.
loads the contents of the internal table itab line by line to the file 'C:\DOWNLOAD.BIN' on the frontend PC. The transferred data is converted. Each line in itab corresponds to a line in the generated file.
07-13-2005 6:37 AM
Hi,
PARAMETERS p_fnam2 LIKE rlgrap-filename.
FORM f1204_download_to_pcfile.
DATA: lv_fname TYPE string.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = p_fnam2
filetype = 'DAT'
TABLES
data_tab = i_download
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 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.
MESSAGE i352. "File downloded successfully
ENDIF.
Regards,
Anjali
07-13-2005 6:38 AM
Hi Mithlesh,
The UPLOAD/DOWNLOAD function modules are now considered obsolete. You should instead use the FMs GUI_UPLOAD and GUI_DOWNLOAD.
Regards,
Anand Mandalika.
07-13-2005 8:11 AM
You can just analyse this simple code Guess this will help you. here i am writing a error log to the presentation server.
FORM f_write_to_potextload_logfile .
OPEN DATASET v_pologt FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
MESSAGE e003 WITH text-018 v_pologt. " UNABLE TO OPEN FILE
EXIT.
ENDIF.
TRANSFERING THE EXTRACTED DATA INTO THE FILE.
LOOP AT i_logfile.
TRANSFERING THE DATA TO FILE
TRANSFER i_logfile TO v_pologt.
ENDLOOP. "i_logfile
IF sy-subrc <> 0.
MESSAGE e003 WITH text-019 v_pologt. " NO RECORDS WERE TRANSFERD
ELSE.
MESSAGE e003 WITH text-020 v_pologt. " TOTAL RECORD
" WERE TRANSFERD
ENDIF."sy-subrc
CLOSE DATASET v_pologt.
ENDFORM. " f_write_to_POtextload_logfile