04-10-2008 5:14 AM
Hi,
I am using the following code to download to a file.In debugging everything seem to be transferred but I am unable to find such a file in the c:/
Kindly help.
Thanks.
data : ofile(128) TYPE c VALUE
'C:\train_status1.txt'.
OPEN DATASET ofile FOR OUTPUT IN BINARY MODE.
IF sy-subrc <> 0.
MESSAGE i204 WITH ofile.
EXIT.
ENDIF.
LOOP AT it_output.
TRANSFER it_output TO ofile.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Unable to write data in file' ofile.
ENDIF.
ENDLOOP.
CLOSE DATASET ofile.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Error while closing file-' ofile.
ENDIF.
SKIP.
WRITE:/ 'Data Download Completed Successfully.'.
04-10-2008 5:18 AM
Using OPEN DATASET you cannot dwn load a file from presentation server(Local System).It will check the files from application server.(Server). So make sure that the corresponding file is available in application server.
Edited by: Rengith Skariah on Apr 10, 2008 6:19 AM
04-10-2008 5:20 AM
HI,
U r using Application server. U should serch in TCODE AL11.
There it will be there.
Regards,
Brown.
04-10-2008 5:22 AM
Hi Renu,
If you want to download file to your desktop, you use function module
GUI_DOWNLOAD.
OPEN DATASET is only to download file in application server.
Thanks,
Arun
04-10-2008 5:25 AM
hi,
Check out in this way ... If you want to download it to Application server ... else use GUI_DOWNLOAD FM to download on to presentation layer ....
data : ofile like rlgrap-filename value
'/usr/sap/tmp/file.txt'. " Aplication Server Path
04-10-2008 5:32 AM
Hi,
Declare
DATA : v_rec TYPE STRING.
OPEN DATASET ofile FOR OUTPUT IN BINARY MODE.
IF sy-subrc 0.
MESSAGE i204 WITH ofile.
EXIT.
ENDIF.
LOOP AT it_output.
CONCATENATE it_output-field1 it_output-field2 it_output-field3
*INTO v_rec SEPARATED BY ',' *
TRANSFER v_rec TO ofile.
IF sy-subrc 0.
MESSAGE e000 WITH 'Unable to write data in file' ofile.
ENDIF.
ENDLOOP.
CLOSE DATASET ofile.
IF sy-subrc 0.
MESSAGE e000 WITH 'Error while closing file-' ofile.
ENDIF.
Now it will work.
Pls. reward if useful....
04-10-2008 10:16 AM
this should defenitely work..
FORM output_data USING p_file.
DATA: lv_file(100) TYPE c,
lv_wa TYPE <database table>,
lv_output(150) TYPE c.
lv_file = <file location>
CONCATENATE lv_file
sy-datum
sy-uzeit
p_file
INTO lv_file.
OPEN DATASET lv_file FOR OUTPUT IN TEXT MODE.
LOOP AT itab INTO lv_wa.
CLEAR lv_output.
CONCATENATE
lv_wa-field1
lv_wa-field2
INTO lv_output
SEPARATED BY '|'.
TRANSFER lv_output TO lv_file.
ENDLOOP.
CLOSE DATASET lv_file.
MESSAGE i999 WITH 'File downloaded to' lv_file.
WRITE:/ lv_file.
regards
Edited by: sudheer sun on Apr 10, 2008 10:17 AM