Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Downloading to a file

Former Member
0 Kudos

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.'.

6 REPLIES 6

Former Member
0 Kudos

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

Former Member
0 Kudos

HI,

U r using Application server. U should serch in TCODE AL11.

There it will be there.

Regards,

Brown.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

http://www.sapdev.co.uk/file/file_downloadpc.htm

Former Member
0 Kudos

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....

Former Member
0 Kudos

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