2007 May 16 8:33 AM
Hello friends,
I have a very simple example, ( writing a string to file ), but dont know what I am doing wrong:
TABLES sflight.
data: flighttab type standard table of sflight .
data: xml_out type string .
select * from sflight into table flighttab .
call transformation (`ID`)
source
output = flighttab[]
result xml xml_out.
DATA:
dsn(30) TYPE C VALUE 'C:\tmp\write\test.xml',
rec(80) TYPE C.
OPEN DATASET dsn FOR OUTPUT IN BINARY MODE .
IF sy-subrc <> 0.
EXIT.
ENDIF.
TRANSFER xml_out TO dsn. "'c:\tmp\flights.xml'.
CLOSE DATASET dsn.
the file is opened correctlly, but on transfer i did not get any exception either, but its not writing on the local drive ? any idea, what I am doing wrong, ..
Regards,
2007 May 16 8:40 AM
Hello,
Try giving a different directory name.
and use encoding default.
oops..I didn't check ur code properly,
Chandrasekahr is right !!!
U can't use a Opendataset to write into a local file.
U got to use Gui_Upload .
Check this sample code:-
chk this sample code.
types: begin of tdat,
fld1(10) type c,
fld2(10) type c,
fld3(10) type c,
end of tdat.
data: itab type table of ttab with header line.
data: idat type table of tdat with header line.
data: file_str type string.
parameters: p_file type localfile.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
file_str = p_file.
call function 'GUI_UPLOAD'
exporting
filename = file_str
tables
data_tab = itab
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.
delete itab index 1.
loop at itab.
clear idat.
split itab-rec at cl_abap_char_utilities=>horizontal_tab
into idat-fld1
idat-fld2
idat-fld3.
append idat.
endloop.
loop at idat.
write:/ idat-fld1, idat-fld2, idat-fld3.
endloop.
Regards,
Deepu.K
2007 May 16 8:41 AM
Hi Shah,
you cannot use Open DATASET to write to a file on presentation server, it is used only to write file on application server
use GUI_DOWNLOAD FM for the same
2007 May 16 8:44 AM
Hi,
OPEN DATASET dsn FOR OUTPUT IN BINARY MODE .
IF sy-subrc <> 0.
EXIT.
ENDIF.
LOOP at XML_OUT.
TRANSFER xml_out TO dsn. "'c:\tmp\flights.xml'.
ENDLOOP.
CLOSE DATASET dsn.
Regards
Sudheer
2007 May 16 8:50 AM
Hi,
Thanks for your reply,
The problem is I have to just write the "String" into the file, where as gui_download use internal table etc....
Is there no way to open/ create a file and just write the string to that file ?
Regards,
2007 Jun 26 10:07 AM
Hello.
I have the same problem than you. Did you have found any solution in the meantime?
Best Regards
Gerhard
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |