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: 

Open Dataset - file downloading problem

Former Member
0 Kudos

Hello friends,

I am trying to download a file in the application sever.But I am getting the error "Error in downlaoding file".What is the mistake in the following code?

Regards,

Hari prasath.

DATA : BEGIN OF ITAB OCCURS 0,

KUNNR LIKE KNA1-KUNNR,

END OF ITAB.

DATA : FN LIKE RLGRAP-FILENAME.

SELECT KUNNR FROM KNA1 INTO CORRESPONDING FIELDS OF TABLE ITAB UP TO 5 ROWS.

FN = 'i2\data\debitnote\kunnr'.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

FILENAME = FN

FILETYPE = 'DAT'

TABLES

DATA_TAB = ITAB.

OPEN DATASET FN FOR OUTPUT IN TEXT MODE.

CLOSE DATASET FN.

2 REPLIES 2

amit_khare
Active Contributor
0 Kudos

we dont use download FM for application servers.

Check this link -

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ccd358411d1829f0000e829fbfe/content.htm

Check this thread, you wll get a complete example on this one.

Regards,

Amit

Reward all helpful replies.

Former Member
0 Kudos

Hi

Do not use the WS_DOWNLOAD FM. Its obsolete.

Insted try this code.

DATA : BEGIN OF ITAB OCCURS 0,

KUNNR LIKE KNA1-KUNNR,

END OF ITAB.

DATA : FN LIKE RLGRAP-FILENAME.

SELECT KUNNR FROM KNA1 INTO CORRESPONDING FIELDS OF TABLE ITAB UP TO 5 ROWS.

FN = 'i2\data\debitnote\kunnr'.

  • Open the file for writing

open dataset FN for output in text mode encoding default.

  • Write the Itab contents to the file

loop at ITAB.

transfer ITAB to FN.

endloop.

close dataset FN.