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: 

rename a folder after using method file_open_dialog

Former Member
0 Kudos
192

Hi all ,

I m using a method cl_gui_frontend_services=>file_open_dialog , but when i want to renam the folder containing the selected file it show a window error (cannot rename foldername : it is being used by another person or program...) , even i exit the SAP.

thanks ,

karim

6 REPLIES 6

former_member181995
Active Contributor
0 Kudos
154

No matters you exit ..may be some else using this in change mode,

Check entries from SM12.

Former Member
0 Kudos
154

nothing in SM12 .

I try to rename the folder manualy in my hard disk ,

example

if i open the file C:\new folder 1\ test.txt , when i want to rename new folder , i had the error

i have the code below


report test  .
Parameters : AUSZFILE LIKE RFPDO1-FEBUMSF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR AUSZFILE.


  DATA: L_FILES TYPE FILETABLE,
        H_FILES TYPE FILE_TABLE,
        L_RC LIKE SY-SUBRC.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
*  EXPORTING
*    window_title            =
*    default_extension       =
*    default_filename        =
*    file_filter             =
*    with_encoding           =
*    initial_directory       =
*    multiselection          =
  CHANGING
    file_table              =  L_FILES
    rc                      = L_RC
*    user_action             =
*    file_encoding           =
*  EXCEPTIONS
*    file_open_dialog_failed = 1
*    cntl_error              = 2
*    error_no_gui            = 3
*    not_supported_by_gui    = 4
*    others                  = 5
        .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*********** 

thanks .

0 Kudos
154

First you must check whether file is exsist or not?

from these below methods:

CALL METHOD cl_gui_frontend_services=>FILE_EXIST

Than get file attributes:

CALL METHOD cl_gui_frontend_services=>FILE_GET_ATTRIBUTES

Than change name from method FILE_SET_ATTRIBUTES.

And if you are make sure of existance than you can change file name in one step

like

CALL METHOD cl_gui_frontend_services=>file_copy
      EXPORTING
        SOURCE               = l_newdoc_file"Old file name
        DESTINATION          = l_layout_file"New file name:give here same destinatation of old file name but name shoud be different,so it will rename it.
        overwrite            = true

Former Member
0 Kudos
154

Hi Amit.

i want just to be able to change the name of the folder manualy by 2 click when i finish the execution of my program nothing less nothing more .

thanks

karim

0 Kudos
154

Why not you are using CALL METHOD cl_gui_frontend_services=>file_copy?As same way i suggested in my above reply.it will change programatically once you pass source and destination file path.

And for manually change from SAP by 2 click i'm not sure.

Former Member
0 Kudos
154

its possible that im not explain clearly my requirement , when i select i file using

file_open_dialog example c:\folder1\file.txt , and i finish the execution of the program , i try

to rename the folder "folder1" ,then i go to the hard disk C: and when i try to rename it manualy i had the error