2008 Jul 16 11:04 AM
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
2008 Jul 16 11:09 AM
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
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
2008 Jul 16 11:06 AM
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
2008 Jul 16 11:09 AM
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
2008 Jul 16 11:14 AM
>
> 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?
2008 Jul 16 11:10 AM
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
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |