09-19-2006 3:16 PM
Hi abapers,
the "open dataset"-command opens a datafile within the given directory. if this file already exists, the system clears all content of this file. Is there any chance to avoid this situation?
thx a lot for help,
marcel
09-19-2006 3:48 PM
thx a lot for fast answer,
my problem is, that in no cases it should be possible to change an existing datafile. Or if a user opens the same datafile, he should be able to choose, if he want to overwrite the existing file or to chooose an other filename.
is there any chance to solve that?
thanks a lot,
marcel
09-19-2006 3:18 PM
use APPENDING MODE instead of just <b>FOR OUTPUT</b>
example :
Opening a File for Appending Data
To open a file so that you can append data to the end of it, use the FOR APPENDING addition in the OPEN DATASET statement:
Syntax
<b>OPEN DATASET <dsn> FOR APPENDING.</b>
regards
srikanth
Message was edited by: Srikanth Kidambi
09-19-2006 3:19 PM
Hello,
OPEN the file in APPEND mode if you want to continue writing in the same file.
OPEN XXXXXX FOR APPENDING .
Regs,
Venkat Ramanan N
09-19-2006 3:20 PM
hi,
Open dataset datasetname for <b>appending</b> .....
Use appending, instead of output, then the contents of the file will not be erased when the file exists. If the file is not exisitng, it creates a new file again.
Regards,
Sailaja.
09-19-2006 3:20 PM
Hi ,
Did you try the option <b>APPPEDNING</b> ?
OPEN DATASET dsn.
Additions:
1. ... FOR INPUT
2. ... FOR OUTPUT
3. ... FOR APPENDING
4. ... IN BINARY MODE
5. ... IN TEXT MODE
6. ... AT POSITION p
7. ... TYPE ctrl
8. ... MESSAGE mess
9. ... FILTER f
Regards,
Varun .
09-19-2006 3:22 PM
09-19-2006 3:48 PM
thx a lot for fast answer,
my problem is, that in no cases it should be possible to change an existing datafile. Or if a user opens the same datafile, he should be able to choose, if he want to overwrite the existing file or to chooose an other filename.
is there any chance to solve that?
thanks a lot,
marcel
09-19-2006 5:35 PM
if you are taking the file name from the selection screen,then you can do like this.
P_FILENAME Is your Selection-screen parameter to hold the file name on application server.
AT SELECTION-SCREEN.
*--Validate application server file.
<b> OPEN DATASET P_FILENAME <b>for INPUT</b> in TEXT MODE
encoding Default.
*--Here we are just checking the FILE already exists or not.by opening the file in INPUT MODE</b>
if sy-subrc = 0.
*--subrc = 0 means,already file exists. so you can give an information/error message to the user,that file already exists.
close dataset v_filename.
endif.
Regards
srikanth
Message was edited by: Srikanth Kidambi