06-12-2009 4:53 PM
Hi all
I am writing a function to write a log. I would like to store informations on a file on local system. This lo g is for a batch. I would like to know if is it possible to append a single line to a file: each time there a record is analyzed I would like to put some information about operation done on the log. Is it possible to append lines to the log file (lile on linux log) so that if the report crash the log contain the last line before crash or the only way is to reload file, update it and store each time?
thanks to who can help me.
gabriele
06-14-2009 10:53 AM
Hi,
FORM DWLD_DATA .
data: w_start(1) type c.
data: w_file type string.
move '1' to w_start.
move 'C:\MYTESTFILE.DAT' to w_file.
call function 'GUI_DOWNLOAD'
exporting
* BIN_FILESIZE =
filename = w_file
filetype = 'ASC'
append = w_start
confirm_overwrite = 'X'
* IMPORTING
* FILELENGTH =
tables
data_tab = l_output
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
ENDFORM.
Rgds,
Ramani N
06-12-2009 4:56 PM
If you mentioned "local system" is a presentation server , then use fm GUI_DOWNLOAD with import parameter APPEND
a®
06-13-2009 4:15 PM
Simple enough in few words....
1) If you are doing the actual processing of records in background mode and if you want to log that data, then you can build a file and place it on the application server, but not on presentation server(local system).
2) If you are doing the actual processing of records in foreground mode and if you want to log that data, then you can build a file and place it in any of your drives either it could be C:/ or D:/ or E:/ if it is windows..or any other directory if it is Unix/Linux.
3) But, you cant log a local copy in ur presentation server while running the job in the background mode. This is because background job would fail abruptly whenever it encounters the FM GUI_DOWNLOAD.
Hope you are clear with the above 3 points.
Thanks,
Babu Kilari
06-14-2009 10:53 AM
Hi,
FORM DWLD_DATA .
data: w_start(1) type c.
data: w_file type string.
move '1' to w_start.
move 'C:\MYTESTFILE.DAT' to w_file.
call function 'GUI_DOWNLOAD'
exporting
* BIN_FILESIZE =
filename = w_file
filetype = 'ASC'
append = w_start
confirm_overwrite = 'X'
* IMPORTING
* FILELENGTH =
tables
data_tab = l_output
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
ENDFORM.
Rgds,
Ramani N