File name from file path

Hi Friends,
i am using METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
i want to know the file name selected from the path.
example : c:\folder\file.txt.
here i want to know which file i have selected. if it is a small path then we can use SPLIT command but if the path selected is long with special chareters then?
urget requirement.
regards
Kumar M.

u can use this function...
CALL FUNCTION 'WS_FILENAME_GET'
   EXPORTING
     DEF_PATH         = 'C:\'
     MASK             = '*.xls'
     MODE             = 'O'
     TITLE            = SY-TITLE
   IMPORTING
     FILENAME         = FILENAME
   EXCEPTIONS
     INV_WINSYS       = 1
     NO_BATCH         = 2
     SELECTION_CANCEL = 3
     SELECTION_ERROR  = 4
     OTHERS           = 5.
have a nice day...

Similar Messages

  • Seperating file name from the path

    Hi,
    im trying to validate the file path and trying to seperate file name from the path.
    for eg.
    if the path is f:\sapfilepath\doc\ext.txt
    need to get f:\sapfilepath\doc  im looking for a dynamic way of doing this.
    your help will be appreciated.
    Regards,
    ravi.

    Hi,
    Use the function module
    SO_SPLIT_FILE_AND_PATH
    Thanks,
    Naren

  • File name from a path

    hi ,
    there is a path "c:\abc\abc\abc\abc\abc.doc", i have to get file name from it.
    but i had to write a dynamic code which can get the file name from any given path.

    Smoke me a kipper, I'll be back before breakfast.
    SQL> var extended_filepath varchar2(128)
    SQL> exec :extended_filepath := '/this/is/a/path/to/a/file.txt'
    PL/SQL procedure successfully completed.
    SQL> select instr(:extended_filepath, '/', -1)
      2  from dual
      3  /
    INSTR(:EXTENDED_FILEPATH,'/',-1)
                                  21
    SQL> select substr(:extended_filepath, instr(:extended_filepath, '/', -1) +1)
      2  from dual
      3  /
    SUBSTR(:EXTENDED_FILEPATH,INSTR(:EXTENDED_FILEPATH,'/',-1)+1)
    file.txt
    SQL> Cheers, APC

  • How to get file name from file adapter (Read Operation)

    Hi All,
    I am reading files from local location, in jca file i gave filename property =*.* ( which reads all files), and now I want to read the incoming file name inside bpel and I want to copy the file name to some variable. Is this possible?

    Yes, its possible.
    In your receive activity,set below property in its properties tab:
    <bpelx:property name="jca.file.FileName" variable="FileName"/>
    Before that make sure to create a variable "FileName" of string type.
    Whatever file your file adapter will read,its name will be stored in this variable.
    Hope this helps.
    Regards,
    Karan
    http://learn-oraclesoa.blogspot.com/

  • File Name from File Adpter in IDOC

    Hi all,
    We have scenario of file->xi->zidoc.
    Now in one field for segement  i also want to store the file name which has been processed by xi , is there anyway to get it ?
    Thanks & Regards,
    Tuhin

    Hi Holger,
    Thanks but can u guide  me how to include  customize code  in module for communication channel and does it need to be EJB only or jar file can also be included.
    If i get filename thorough this customize code but how to get this name in graphical mapping ??
    Please send me any code or docs on [email protected] .
    Thanks & Regards,
    Tuhin

  • Using the array of file names from File.list()

    Hi
    I'm having trouble with my code, similar to this:
    File temp=new File(path); //where 'path' is a String containing the directory path
    String [ ] arr = temp.list();
    Then when trying to use arr, I come up with NullPointerExceptions.
    The Java API says that the File.list() method returns a Stirng array.
    But then how do I use/get this array in a nice usable form?
    (eg. to be able to loop through the list of {returned} Files)

    Yes I have referred closely to the documentation.
    The method list() for my File object is definitely not returning null;
    it seems that as soon as the code inside the loop tries to access the next element of the returned array [the one after the last existing element] - which is actually non-existent (ie overstepped the bounds of the array's index) - the program comes up with an Exception*. So the method list() does not return null...
    I have managed a workaround similar to this:
            File temp = new File (path);
            String[] list = new String [temp.list ().length + 1];
            try
                for (int i = 0 ; temp.list () != null ; i++)
    list [i] = temp.list () [i];
    catch (ArrayIndexOutOfBoundsException iobe)
    * The program is not coming up with NullPointerExceptions anymore; only an ArrayIndexOutOfBoundsException if I comment out the try and catch coding.... (?)
    Thanks for your suggestion about posting this at the Java Programming Forum.
    My workaround works, but is there a way to do this without catching an exception?

  • Retrieve file name from full file path

    I am trying to retrieve a file name from a path (ex. c:\temp\tes.txt) using the following code, but it is given me an error of "The method split(String) in the type String is not applicable for the arguments (char).
    {code}
    String filepath = item.getName();
    String[] buf = filepath.split('/');
    String filename = buf[buf.length-1];
    {code}
    I tried to use double quote instead of single quote, but it is not returning anything.
    {code}
    String[] buf = filepath.split("/");
    {code}
    Anyone knows why? Thanks.

    How is this related to JDBC?
    Anyway, is the path separator actually a forward slash? Isn't it a backward slash?
    If you're using Apache Commons FileUpload (which I guess, the 'item.getName()' is recognizeable), then just read their FAQ: [http://commons.apache.org/fileupload/faq.html#whole-path-from-IE].

  • Need to extract only file name from path.........

    Hi All,
    I have a parameter.This calls the function
    "CALL FUNCTION 'F4_FILENAME' to get the file from C drive.
    After selecting the file the path is displayed in the Parameter field.
    My problem is I need to extract only file name from the path.Please advice.
    Example : Prameter  id    C:\folder\file.xls  
    I shd extract only file.xls from the path.Please advice.

    Hi,
    Use the below logic:
    data: begin of itab,
               val    type  char20,
            end of itab.
    SPLIT  l_f_path  AT  '\'  INTO  TABLE itab.
    The last record of the internal table holds the file name.
    describe table itab lines l_f_lines.
    read itab index l_f_lines.
    l_f_filaname = itab-val.
    Hope this helps u.

  • Obtaining file name from the file path given

    hi,
    how to obtain  file name from the file path given

    Hi bharath,
    1. PC_SPLIT_COMPLETE_FILENAME
    2.
    DATA : path LIKE pcfile-path.
    DATA : extension(5) TYPE c.
    path = filename.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    * CHECK_DOS_FORMAT =
    IMPORTING
    * DRIVE =
    extension = extension
    name = name
    * NAME_WITH_EXT =
    * PATH =
    EXCEPTIONS
    invalid_drive = 1
    invalid_extension = 2
    invalid_name = 3
    invalid_path = 4
    OTHERS = 5
    regards,
    amit m.

  • Flat file connection: The file name "\server\share\path\file.txt" specified in the connection was not valid

    I'm trying to execute a SSIS package via SQL agent with a flat file source - however it fails with Code: 0xC001401E The file name "\server\share\path\file.txt" specified in the connection was not valid.
    It appears that the problem is with the rights of the user that's running the package (it's a proxy account). If I use a higher-privelege account (domain admin) to run the package it completes successfully. But this is not a long-term solution, and I can't
    see a reason why the user doesn't have rights to the file. The effective permissions of the file and parent folder both give the user full control. The user has full control over the share as well. The user can access the file (copy, etc) outside the SSIS
    package.
    Running the package manually via DTExec gives me the same error - I've tried 32 and 64bit versions with the same result. But running as a domain admin works correctly every time.
    I feel like I've been beating my head against a brick wall on this one... Is there some sort of magic permissions, file or otherwise, that are required to use a flat file target in an SSIS package?

    Hi Rossco150,
    I have tried to reproduce the issue in my test environment (Windows Server 2012 R2 + SQL Server 2008 R2), however, everything goes well with the permission settings as you mentioned. In my test, the permissions of the folders are set as follows:
    \\ServerName\Temp  --- Read
    \\ServerName\Temp\Source  --- No access
    \\ServerName\Temp\Source\Flat Files --- Full control
    I suspect that your permission settings on the folders are not absolutely as you said above. Could you double check the permission settings on each level of the folder hierarchy? In addition, check the “Execute as user” information from job history to make
    sure the job was running in the proxy security context indeed. Which version of SSIS are you using? If possible, I suggest that you install the latest Service Pack for you SQL Server or even install the latest CU patch. 
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • Logical file name or logical path name incorrectly defined

    Dear All,
    We are doing archival in our IDES for test purpose before we do it to our Production.
    Steps Performed
    Copied AM_ASSET archive object to ZAM_ASSET
    Logical Path
      Logical path    ZAM_ASSET
      Name            Asset
      Syntax group    UNIX       Unix compatible
      Physical path   /archive/test/<FILENAME>
    Logical File Name
       Logical file    ZAMASSET
       Name            Asset
       Physical file   FI_<MONTH>_<DAY>.txt
       Data format     ASC
       Applicat.area   AM
       Logical path    ZAM_ASSET
    But when we run the WRITE though SARA , in the job log we get the following
    Logical file name or logical path name incorrectly defined
    When generating a file name for an archive file that is to be created, the system determined that the logical file name FIAA_ARCHIVE_DATA_FILE or the logical path name ARCHIVE_GLOBAL_PATH  was defined incorrectly.
    But we have maintained a Logical name  ZAMASSET , so we are unable to change the location of archived file and as well as the format.
    So is there any setting we need to maintain apart from the logical file name and logical file path.
    Suggestions are highly appreciated.
    Thanks in anticipation

    hi,
    follow this steps :
    - transaction SARA
    - enter authorization objects, eg SD_VBAK
    - hit button CUSTOMIZING
    - Archiving Object-Specific Customizing: execute Technical Setting
    - field Logical File Name enter or select ARCHIVE_DATA_FILE
    - leave CONTENT REPOSITORY as blank if you are not using 3rd party for storing (eg. IBM Tivoli)
    - back to customizing
    - from Basis Customizing, execute : Cross-Client File Names/Paths
    - on Logical FIle Path Definition, highlight (select) ARCHIVE_GLOBAL_PATH on the right pane
    - double click on the Assignment of Physical Paths to Logical Path on the left pane
    - double click on OS used, eg. UNIX, define Physical Path where archive file (on WRITE process) will be stored
    - save changes made
    - double click Logical File Definition, Cross Client on the left pane
    - double click ARCHIVE_DATA_FILE on the right pane
    - make sure that logical path is already set to ARCHIVE_GLOBAL_PATH
    - save changes made
    this setting also can be done using transaction FILE
    we have experienced on this case using SAP standard archiving (SARA, SARI) and everything is fine with this setting above.
    hope it help you.
    rgds,
    Alfonsus Guritno

  • How to get the target file name from an URL?

    Hi there,
    I am trying to download data from an URL and save the content in a file that have the same name as the file on the server. In some way, what I want to do is pretty similar to what you can do when you do a right click on a link in Internet Explorer (or any other web browser) and choose "save target as".
    If the URL is a direct link to the file (for example: http://java.sun.com/images/e8_java_logo_red.jpg ), I do not have any problem:
    URL url = new URL("http://java.sun.com/images/e8_java_logo_red.jpg");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Everything is fine, the file name I get is "e8_java_logo_red.jpg", which is what I expect to get.
    However, if the URL is an indirect link to the file (for example: http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719 , which link to a file named JavaSetup6u18-rv.exe ), the similar code return AutoDL?BundleId=37719 as file name, when I would like to have JavaSetup6u18-rv.exe .
    URL url = new URL("http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Do you know how I can do that.
    Thanks for your help
    // JB
    Edited by: jb-from-sydney on Feb 9, 2010 10:37 PM

    Thanks for your answer.
    By following your idea, I found out that one of the header ( content-disposition ) can contain the name to be used if the file is downloaded. Here is the full code that allow you to download locally a file on the Internet:
          * Download locally a file from a given URL.
          * @param url - the url.
          * @param destinationFolder - The destination folder.
          * @return the file
          * @throws IOException Signals that an I/O exception has occurred.
         public static final File downloadFile(URL url, File destinationFolder) throws IOException {
              URLConnection urlC = url.openConnection();
              InputStream is = urlC.getInputStream();
              FileOutputStream fos = null;
              String fileName = getFileName(urlC);
              destinationFolder.mkdirs();
              File localFile = new File(destinationFolder, fileName);
              fos = new FileOutputStream(localFile);
              try {
                   byte[] buf = new byte[1024];
                   int i = 0;
                   while ((i = is.read(buf)) != -1) {
                        fos.write(buf, 0, i);
              } finally {
                   if (is != null)
                        is.close();
                   if (fos != null)
                        fos.close();
              return localFile;
          * Returns the file name associated to an url connection.<br />
          * The result is not a path but just a file name.
          * @param urlC - the url connection
          * @return the file name
          * @throws IOException Signals that an I/O exception has occurred.
         private static final String getFileName(URLConnection urlC) throws IOException {
              String fileName = null;
              String contentDisposition = urlC.getHeaderField("content-disposition");
              if (contentDisposition != null) {
                   fileName = extractFileNameFromContentDisposition(contentDisposition);
              // if the file name cannot be extracted from the content-disposition
              // header, using the url.getFilename() method
              if (fileName == null) {
                   StringTokenizer st = new StringTokenizer(urlC.getURL().getFile(), "/");
                   while (st.hasMoreTokens())
                        fileName = st.nextToken();
              return fileName;
          * Extract the file name from the content disposition header.
          * <p>
          * See <a
          * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html">http:
          * //www.w3.org/Protocols/rfc2616/rfc2616-sec19.html</a> for detailled
          * information regarding the headers in HTML.
          * @param contentDisposition - the content-disposition header. Cannot be
          *            <code>null>/code>.
          * @return the file name, or <code>null</code> if the content-disposition
          *         header does not contain the filename attribute.
         private static final String extractFileNameFromContentDisposition(
                   String contentDisposition) {
              String[] attributes = contentDisposition.split(";");
              for (String a : attributes) {
                   if (a.toLowerCase().contains("filename")) {
                        // The attribute is the file name. The filename is between
                        // quotes.
                        return a.substring(a.indexOf('\"') + 1, a.lastIndexOf('\"'));
              // not found
              return null;
         }

  • How to store the File Name from a Unix Directory into a ODI variable?

    Hi,
    I have built a ODI package with the following steps:
    1. ODI is polling for a flat file in a Unix directory. I have used OdiFileWait tool for this purpose. Here the file name is not fixed, so I am using wild character (*) to poll for file. Example: DF*ABC1*.DAT where the first wild character denotes 1 letter and the second wild character denotes 2 digits.
    2. In the second step, if the file is found, I am moving the file to ODI file server path (../oracledi/demo/file). Here I have used ODIFileMove tool.
    3. Then I am using an ODI Interface to Load the file data into a Oracle database table.
    4. I am using a Process log table to keep the log for each step I am executing in ODI that is ODIFileWait, ODIFileMove, Interface etc. for each file. In this table a row needs to be inserted after ODIFileWait tool gets the file, with the File Name and File Date. Later on this row will be updated as the consequent steps are executed.
    Here is my concern, I need to get the exact File Name of the file after ODIFileWait gets the file and I need to insert that in the Process Log table after the ODIFileWait step gets a file. So if I can store the File Name in a ODI Variable, I can insert it into the Process log table at this point. This I am not able to do.
    The files are coming in a different directory (not in ODI file server path), So after getting the file it is moved to ODI file server path (../oracledi/demo/file)
    The Files which I am processing are fixed length format. Also, the File name and File Date is stored in the 1st Record(Header record) of the files.
    Kindly provide me suggestions to implement this in my code.
    Thanks and Regards,
    Anik
    Edited by: 809820 on Nov 10, 2010 11:36 PM

    Look at this link -http://odiexperts.com/getting-one-or-several-unknown-files-from-a-directory
    change the command to fetch the ls command and write into File and then using either java or jython break the data and fetch the file name and date and insert into log table.
    (or)
    you can use the os.system command and get the complete ls command into string and then process and insert it.
    Let us know if you need any other help.

  • File Name and File Content  not gettinng passed from Proxy to Business Serv

    Hi All ,
    I have a requirement in OSB , where i need to pick the file from remote Source and FTP the files to Remote Target .Below are the steps which i did to achieve this.
    1.Created a FTP Adapter in JDeveloper to Get the files from Source and a FTP Adpater to Put the files to Target.Inboth the adapters i have choose 'Shema is Opaque'
    2.Imported the wsdl and jca file to OSB
    3.Generated Proxy Service (PS ) and Business service (BS) out of Step 2
    4.I edited the Message flow such a way that , the PS is routed to invoke the BS
    Aslo i assigned $inbound/ctx:transport/ctx:request/tp:headers/jca:jca.file.FileName to a variable 'FileName' in PS
    and in BS service i passed $outbound/ctx:transport/ctx:request/tp:headers/jca:jca.ftp.FileName = 'FileName'
    When i tried to activate my session , the file that is getting written to the target has 0 byte.Also , the file name is also not getting passed from PS to BS
    Can some one help me with the steps on how to use the Xpath , so as to pass the file name and file body from proxy servive to business service.
    Thanks
    John

     I search multiple shares to find a common file name then create a single output file. I will be doing this search and file creation
    for 5-10 different file names. If there is a better way .. certainly open for suggestions. It's working but having issue with
    the cmd file for every file and folder I check. It puts this error out for each run of the process.
      Error message in LOG file:
    Get-ChildItem : Cannot find path 'F:\powershell\-SearchFor' because it does not exist.
     Thanks.
    I tried your code with little changes and saved in Temp folder.
    My CMD file has the below code
    PowerShell C:\Temp\Untitled1.ps1
    It worked.
    Regards Chen V [MCTS SharePoint 2010]

  • File type from file name

    Hi,
    Is there any standard method to get a file type from file name?
    File name can be ‘C:\test.doc’ or “C:\test’(test – is file) i.e. with or without file type extension.
    ...Naddy

    You can use the Function module PC_SPLIT_COMPLETE_FILENAME
    export paramter extension will tell the type of file
    Sample Output
    Import     COMPLETE_FILENAME     C:\TEST.TXT
    Import     CHECK_DOS_FORMAT     
    Export     DRIVE     C
    Export     EXTENSION     TXT
    Export     NAME     TEST
    Export     NAME_WITH_EXT     TEST.TXT
    Export     PATH     \

Maybe you are looking for

  • OCIStmtExecute does not return immediately when client is busy.

    Hi. I'm testing a very busy multi-threaded client server that consistently generates a large number of simple queries through oci. The problem is that, when the server(client) is busy, OCIStmtExecute does not return immediately in non-blocking mode.

  • How to follow a question and not a whole community?

    How to follow a question and not a whole community? THanks.

  • Videos Imported from iPhoto Cannot Play in Photos

    Hello, I just upgraded to Photos and accepted the default setting to convert my iPhoto library to Photos/iCloud format.  All went fine without errors and I see that Photos created an entire duplicate on the iPhoto library. The problem is I cannot pla

  • Search tutorial for HTML code

    Hi everybody, I need help with a project of mine. I want to be able to search through text in orer to find specific data and store that. Basically what I'm trying to do have a text like the following and store certain fields. For example, the values

  • Blue screen after software update

    I did the software update that came up this morning and on restart I get the gray screen with apple then it goes to blue with a flicker every so often. Anybody else with this problem? Advice? At least I can get online with my iPod... Kathy