Application Development and Automation 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: 
Read only

RE: Problem with open dataset

Former Member
0 Likes
547

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
517

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.

5 REPLIES 5
Read only

Former Member
0 Likes
517

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 .

Read only

0 Likes
517

And how can i check, if a datafile already exists?

thanks a lot,

marcel

Read only

Hans
Explorer
0 Likes
517

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.

Read only

Former Member
0 Likes
517

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

Read only

Former Member
0 Likes
518

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.