‎2006 Sep 19 3:50 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
‎2006 Sep 19 3:59 PM
Hi Marcel,
First open the file in the write mode if the file is already there then raise the message using FM popup_to_confirm informing file is already there. if user selects yes, then then open the file in output mode and write the file and in other case just leave the program and allow user to enter another file name.
hope this helps.
‎2006 Sep 19 3:56 PM
Hi ,
You need to handle this explicitly . Try to call a FM pop_to_confirm to make a decision and based upon this try to overwrite or append to existing contents .
Regards,
Varun .
‎2006 Sep 19 3:57 PM
And how can i check, if a datafile already exists?
thanks a lot,
marcel
‎2006 Sep 19 3:57 PM
After you read in the dataset, close the file. When the user opts to save, present him/her with the "file save" dialog. If the user chooses the same name as the original dataset, he/she will be asked to replace or change the file name, because the original dataset is closed.
Hope this helps.
‎2006 Sep 19 3:59 PM
Hi,
Use the Function module <b>/SAPDMC/LSM_F4_SERVER_FILE</b> to open the Application server files ..
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = ' '
filemask = ' '
IMPORTING
serverfile = p_afile
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
in the above code, P_afile will have the file path which user selected, so you will have the file path in that variable, after that you can use OPEN DATASET, READ DATASET.
even you use OPEN DATASET <file path> FOR APPENDING to append the data to the existed file ..
hope you understand
Regards
Sudheer
‎2006 Sep 19 3:59 PM
Hi Marcel,
First open the file in the write mode if the file is already there then raise the message using FM popup_to_confirm informing file is already there. if user selects yes, then then open the file in output mode and write the file and in other case just leave the program and allow user to enter another file name.
hope this helps.