10-01-2013 10:29 AM
I have a folder say 'xyz' on my machine, using just that i want to find out the exact path of this folder on my machine, like say 'c:\abc\xyz'. How can I achieve this. Is there a function module for this or some code that I will have to write ?
10-01-2013 3:33 PM
I am pretty sure you are not able to search your entire host for a random folder name. If the folder name is not random then I assume that the location of the folder is known. In which case you could use logical file names (Transaction FILE).
If you truly do not know the absolute path of your folder then you are looking at having to search the file system of your host - this could take quite sometime and also if the host is Windows Vista or greater then you might well hit issues with UAC as some directories are protected.
Where does the requirement to find the absolute path of an unknown folder name come from? We may be able to find another way for you to achieve your goal.
10-01-2013 10:34 AM
10-01-2013 10:36 AM
Hi,
please have a look at class CL_GUI_FRONTEND_SERVICES.
For example you can use methods FILE_OPEN_DIALOG or FILE_SAVE_DIALOG or one of the DIRECTORY...-methods.
Regards,
Klaus
10-01-2013 10:42 AM
Hey Giri and Klaus,
I have tried most of these function modules but none of them accept a pattern for a directory name like '%xyz%' and return the full path if the directory is found. I don't know whether the folder is on c:, or d: or some other drive.
10-01-2013 11:20 AM
Hi,
I don#t think you will find a fm or method which is searching a frontend path for you. Normally you have to know, where the path is.
But I think you may be able to use the methods of class CL_GUI_FRONTEND_SERVICES to code a search yourself. Start with the root directory (C:\), get content list with method DIRECTORY_LIST_FILES and option DIRECTORIES_ONLY, search all directories recursively, and if the path is not found start with root directory D:\ and so on.
regards,
Klaus
10-01-2013 3:14 PM
And what should happen if more directories follow your pattern ?
I don't think it is possible with a standard function module or method and agree with Klaus that you will need to program this yourself from scratch.
10-01-2013 10:42 AM
Like so:
DATA: IT_FILES TYPE FILETABLE,
WA_FILES LIKE LINE OF IT_FILES,
LV_RC TYPE I.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PCPATH.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG.
EXPORTING
WINDOW_TITLE = 'Select Files'
MULTISELECTION = 'X'
CHANGING
FILE_TABLE = IT_FILES
RC = LV_RC
<i> IT_FILES will contain list of files selected or
name of file selected if
MULTISELECTION = ' '</i>
Hope this helps you.
Regards,
Glen.
10-01-2013 10:46 AM
Hi Mrunal,
Kindly use the following fms if they are working:
FILE_GET_NAME_AND_LOGICAL_PATH,
FILE_GET_NAME_USING_PATH,
FILE_GET_NAME
I guess the first one should work since in this you can assign physical filename and get logical file path.
Hope it helps!!!!
Thanks And Regards,
Alora
10-01-2013 11:27 AM
Hi,
Use the method in the class cl_gui_frontend_services.
v_sel_path contain selected folder path.
DATA: v_sel_path TYPE string.
CALL METHOD cl_gui_frontend_services=>directory_browse
CHANGING
selected_folder = v_sel_path
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
OTHERS = 3 .
Regards,
Jeffin
10-01-2013 11:32 AM
10-01-2013 11:39 AM
Hi,
When executing , a popup window will appear and you can choose the folder. Output parameter v_sel_path will contain the path of the folder .
10-01-2013 12:21 PM
10-01-2013 3:09 PM
Hi Mrunal,
Have a look on the function module 'TMP_GUI_GET_SYSTEMDIR', also go through all the function modules under the function group 'SI72'.
Execute the function module 'TMP_GUI_GET_SYSTEMDIR' it gives the path of the system directory something like C:\Windows\system32
CALL METHOD OF H_COM1 'GetSystemDirectory' = SYSTEMDIR.
In this function module a call is made to the windows function GetSystemDirectory to get the system directory information. Make a search for windows function which are available suitable in your case. If you find such windows function then just copy the function module and replace the windows function. But not sure if there is a readily available windows function that suits your requirement.
Hope this helps.
Thanks,
Tooshar Bendale
10-01-2013 3:33 PM
I am pretty sure you are not able to search your entire host for a random folder name. If the folder name is not random then I assume that the location of the folder is known. In which case you could use logical file names (Transaction FILE).
If you truly do not know the absolute path of your folder then you are looking at having to search the file system of your host - this could take quite sometime and also if the host is Windows Vista or greater then you might well hit issues with UAC as some directories are protected.
Where does the requirement to find the absolute path of an unknown folder name come from? We may be able to find another way for you to achieve your goal.
10-02-2013 5:17 AM
The actual requirement came from the problem where in our organisation admin rights for all users were removed, due to which programs that downloaded DMS documents to the machine started giving errors, that, file could not be created as write access was removed.
The actual requirement now is to download documents to a users "TEMP" folder on a windows/linux machine which would have write access. The download happens through the FM for DMS : CVAPI_DOC_VIEW.
Now to locate this folder(TEMP) on the users machine and then pass this path to the fm CVAPI_DOC_VIEW to download the document, is the tough part, whose solution I was looking for through this question. I shall try with the method Klaus suggested.
Regards,
Mrunal.
10-02-2013 6:30 AM
Hi,
here is a sample fm for getting all folders of a drive in Windows 7. But it isn't very fast, it lasted several minutes for searching 35000 folders on drive C:\ and some seconds for searching 189 folders on drive D:\ .
Regards,
Klaus
10-02-2013 7:22 AM
10-02-2013 11:32 AM
Can you not simply download the file to the SAP AS and then allow the user to open the file from there? You could use a FM to open the file, something like:
CALL FUNCTION 'GUI_EXEC'
EXPORTING
command = 'C:\WINWORD.EXE'
PARAMETER = P_DATA
IMPORTING
RETURNCODE = RETURNCODE .
I know there is a method to call IE as well and pass it a URL. The URL in this case could be your directory path to your file on the SAP AS. IE would then open the file. This might be a better solution then spending a lot of time searching all directories of a local machine? ....
10-03-2013 5:59 AM
Adam,
If I were to download the file to SAP AS, please keep in mind there are some 300 odd users we have and each of them opens at least a 20-30 files with respective data. Imagine saving so many files on the AS. Saving it to the users desktop is definitely the way out. Thanks anyway.
10-02-2013 7:26 AM
Why not create an enviropnment variable on user desktop with the path (like the usual TEMP or TMP) you could then read this variable with method ENVIRONMENT_GET_VARIABLE of CL_GUI_FRONTEND_SERVICES.
Regards,
Raymond
10-03-2013 6:03 AM
Raymond,
Like I said to Adam, the number of users we have is large, thanks anyway.
10-03-2013 9:40 AM
Its a bummer - I was hoping that the users would not have to wait minutes for directory discovery. Users always like things instantly. Hope all works!