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: 

application server file downloading

Former Member
0 Kudos

Hi Experts,

I have very urgent requiremnts for this :

1. The data extract needs to be downloaded on SAP application server ( take whatever path accessible to you).

2. Thereafter for every run, it should check if the file available in the same path and if yes then append data to this file instead of creating new one.

3. If file is not available then create new file.

please suggest me, how to do this.

it's very urgent

Regards

Mohit

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

use following logic

  • Compile the file path

CONCATENATE text-t10 sy-datum c_txt INTO v_fname_out.

  • Open the filepath on the application server for writing

OPEN DATASET v_fname_out FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  • Check if the file could be opened

IF sy-subrc = 0.

  • Loop at the internal table and transfer the contents to the file specified at the path

LOOP AT itab INTO wa.

TRANSFER wa TO v_fname_out FOR APPENDING.

CLEAR wa.

ENDLOOP.

ENDIF.

  • Close the dataset

CLOSE DATASET v_fname_out.

regards,

srilatha

4 REPLIES 4

matt
Active Contributor
0 Kudos

OPEN DATASET dsn FOR APPENDING. As it says in the help

"If the file specified already exists, it is opened and the file pointer is set at the end of the file. If the file specified does not exist, it is created"

Good, isn't it? You don't even have to write any logic.

regards

matt

Former Member
0 Kudos

hi,

use following logic

  • Compile the file path

CONCATENATE text-t10 sy-datum c_txt INTO v_fname_out.

  • Open the filepath on the application server for writing

OPEN DATASET v_fname_out FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  • Check if the file could be opened

IF sy-subrc = 0.

  • Loop at the internal table and transfer the contents to the file specified at the path

LOOP AT itab INTO wa.

TRANSFER wa TO v_fname_out FOR APPENDING.

CLEAR wa.

ENDLOOP.

ENDIF.

  • Close the dataset

CLOSE DATASET v_fname_out.

regards,

srilatha

matt
Active Contributor
0 Kudos

>

> hi,

>

>

> use following logic

>

> * Compile the file path

> CONCATENATE text-t10 sy-datum c_txt INTO v_fname_out.

>

> * Open the filepath on the application server for writing

> OPEN DATASET v_fname_out FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

>

> * Check if the file could be opened

> IF sy-subrc = 0.

>

> * Loop at the internal table and transfer the contents to the file specified at the path

> LOOP AT itab INTO wa.

> TRANSFER wa TO v_fname_out FOR APPENDING.

> CLEAR wa.

> ENDLOOP.

> ENDIF.

>

> * Close the dataset

> CLOSE DATASET v_fname_out.

>

>

> regards,

> srilatha

Yes, but what if the file couldn't be opened?

Former Member
0 Kudos

Hi,

Open the file using 'OPEN DATASET ....'

Loop your internal table where in use command TRANSFER to transfer the contents of the file to application server.

With Regards,

Phani Diwakar.

Edited by: MVPhani Diwakar on Jul 16, 2008 12:11 PM