File Path Validation

Hi,
I have to move my data from my program to a flat file on the Application/ Presentation Server. Now i need to validate whether the path provided by user is a valid one or not.
For eg. If the User enter \usr\sap\ in the presentation server path. The file shd not be saved there instead the user shd get a message to give the correct file path.
And in case of Application Server if the user enters c:\temp it shd not accept. Also if the user gives some random value ksdjfhakf.txt in the file path it shd not take.
Please let me know how can we acheive this.
Regards,
FS

Hi
Validating file path on the Presentation Server
To validate a file path on the presentation server, use the method directory_exist available in the class cl_gui_frontend_services.
Demo program to validate the file path on the presentation server:
REPORT  zdir_test.
TYPE-POOLS: abap.
DATA: v_dir TYPE string.
DATA: v_bol TYPE abap_bool.
v_dir = 'c:\sap\'.
CALL METHOD cl_gui_frontend_services=>directory_exist
  EXPORTING
    directory            = v_dir
  RECEIVING
    result               = v_bol
  EXCEPTIONS
    cntl_error           = 1
    error_no_gui         = 2
    wrong_parameter      = 3
    not_supported_by_gui = 4
    OTHERS               = 5.IF NOT v_bol IS INITIAL.
  WRITE:/ 'Directory exists.'.
ELSE.
  WRITE:/ 'Directory does not exist.'.
ENDIF.
PLZ reward if helpful,
Thanks,
S.Gangi reddy.

Similar Messages

  • File path validation in the background fails - Urgent

    Hi,
    my program is to download files in the presentation server. so iam validating the file path using method CALL METHOD cl_gui_frontend_services=>directory_exist
    but when i execute the program in the back ground its giving dump with a runtime error as OBJECTS_OBJREF_NOT_ASSIGNED.
    could some body help on this
    Neha

    Hi.. neha,
    use this function module..
    EPS_OPEN_INPUT_FILE
    give the file name and directory path as input to this function module..
    if any exception raised like OPEN_FAILED then the file doesnot exist..(sy-subrc value will be set to 6 for this exception )..
    so you can write the code as
    call function '<b>EPS_OPEN_INPUT_FILE</b>'
      exporting
        file_name                    = '<b>ASDA</b>'
       DIR_NAME                     = '<b>D:\usr\sap\R3S\DVEBMGS02\work</b>'
      TEXT_MODE                    = ' '
    IMPORTING
      DIR_NAME                     =
      FILE_PATH                    =
      FILE_SIZE                    =
    EXCEPTIONS
       INVALID_EPS_SUBDIR           = 1
       SAPGPARAM_FAILED             = 2
       BUILD_DIRECTORY_FAILED       = 3
       NO_AUTHORIZATION             = 4
       BUILD_PATH_FAILED            = 5
       OPEN_FAILED                  = 6
       READ_DIRECTORY_FAILED        = 7
       READ_ATTRIBUTES_FAILED       = 8
       OTHERS                       = 9
    <b>if sy-subrc eq 6.
      message 'file does not exist' type 'E'.
    else.
      write : 'file exists.'.
    endif.</b>
    ASDA is an existing file in my application server in the specified directory.. so am getting the message as FILE EXISTS.
    you can see all the directories in Application server in transaction code AL11.
    reward all helpful answers,
    sai ramesh

  • How to check pc file path validity?

    Hi,
       In my program I have to extract so much SAP data and write in a file in the fornt-end PC. In the selection screen I will input the filepath\name to write the data.
    But how should I check whether the filepath is valid or not in the 'AT SELECTION-SCREEN' event itself? so that if it is not valid path, I can give an error message before extracting all the SAP data.
    Thank you!
    Sunitha.

    Hi Sunitha,
    Please check the following sample code from other thread at selection screen value request event.
    Using ABAP Objects:
    PARAMETER : p_file LIKE rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR path.
    DATA: directory TYPE string,                            
          filetable TYPE filetable,                         
          line      TYPE LINE OF filetable,                 
          rc        TYPE i.                                 
    CALL METHOD cl_gui_frontend_services=>get_temp_directory
      CHANGING                                              
          temp_dir = directory.      
    CALL METHOD cl_gui_frontend_services=>file_open_dialog  
      EXPORTING                                             
          window_title      = 'SELECT THE FILE'         
          initial_directory = directory                     
          file_filter       = '*.XLS'                       
          multiselection    = ' '                           
        CHANGING                                            
          file_table        = filetable    
          rc                = rc.                       
    IF rc = 1.                                          
      READ TABLE filetable INDEX 1 INTO line.           
      P_FILE = line-filename.                         
    ENDIF.   
    Using Normal ABAP:
    DATA: P_FILE LIKE RLGRAP-FILENAME,
          DPATH LIKE RLGRAP-FILENAME,
          UPATH LIKE RLGRAP-FILENAME,
          MODE TYPE C,
          FLG_UD TYPE C.
    CALL FUNCTION 'WS_ULDL_PATH'
      IMPORTING
        DOWNLOAD_PATH = DPATH
        UPLOAD_PATH   = UPATH.
    IF FLG_UD <> 'D'.
      DPATH = UPATH.
      MODE = 'O'.
    ELSE.
      MODE = 'S'.
    ENDIF.
    CALL FUNCTION 'WS_FILENAME_GET'
      EXPORTING
        DEF_FILENAME     = '*.XLS'
        DEF_PATH         = DPATH
        MASK             = ',*.XLS,*.*,*.*.'
        MODE             = MODE
      IMPORTING
        FILENAME         = P_FILE
      EXCEPTIONS
        SELECTION_CANCEL = 3.
    IF SY-SUBRC <> 0.
      EXIT.
    ENDIF.
    Hope this will help.
    Regards,
    Ferry Lianto

  • Application server file path vaidation

    I have written the code for application server file path validation.
      DATA : l_fname TYPE filename-fileintern." type c.
      DATA : l_filpath TYPE filename-fileintern,
             l_filname(40) TYPE c.
    PARAMETER : p_sucfil LIKE rfpdo-rfbifile OBLIGATORY. " rlgrap-filename
    AT SELECTION-SCREEN ON p_sucfil.
    l_fname = p_sucfil.
    CALL FUNCTION 'FILE_GET_NAME'
      EXPORTING
      CLIENT                        = SY-MANDT
        logical_filename              = l_fname
       OPERATING_SYSTEM              = SY-OPSYS
      PARAMETER_1                   = ' '
      PARAMETER_2                   = ' '
      PARAMETER_3                   = ' '
      USE_PRESENTATION_SERVER       = ' '
       WITH_FILE_EXTENSION           = 'X'
      USE_BUFFER                    = ' '
      ELEMINATE_BLANKS              = 'X'
    IMPORTING
      EMERGENCY_FLAG                =
      FILE_FORMAT                   =
       FILE_NAME                     = l_filpath
    EXCEPTIONS
       FILE_NOT_FOUND                = 1
       OTHERS                        = 2
    IF sy-subrc <> 0.
      message 'Invalid file name' type 'E'.
    ENDIF.
    But always i will get Invalid file name.
    Y is it so.
    pls help me.

    Praveen,
    I have checked ur code and I found that if i give a logical file name from
    tran. FILE under folder 'Logical file name definition, cross client' then ur code works. Pl. check.
    Regards,
    Joy.
    DATA : l_fname TYPE filename-fileintern." type c.
    DATA : l_filpath TYPE filename-fileintern,
    l_filname(40) TYPE c.
    PARAMETER : p_sucfil LIKE rfpdo-rfbifile OBLIGATORY. " rlgrap-filename
    AT SELECTION-SCREEN ON p_sucfil.
      l_fname = p_sucfil.
      CALL FUNCTION 'FILE_GET_NAME'
      EXPORTING
      logical_filename = l_fname
    operating_system = sy-opsys
      with_file_extension = 'X'
      IMPORTING
      file_name = l_filpath
      EXCEPTIONS
      file_not_found = 1
      OTHERS = 2
      IF sy-subrc <> 0.
        MESSAGE 'Invalid file name' TYPE 'E'.
      ENDIF.

  • File path error in same screen.

    hey guys,
    I want to check my file path validation and display error in same screen itself.
    I used my GUI_UPLOAD method in START OF SELECTION. to read the file.
    If error it displays error in some other plain screen.
    I know AT selection screen will allow me to display in same screen.
    But is the way of using GUI_UPLOAD method in AT selection screen is advisable?
    or else please give me alternate way.
    ambichan

    Hi
    You can use in AT Selection screen
    data result.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
      EXPORTING
        FILE                 =  'C:\test.txt'
      RECEIVING
        RESULT               =
    EXCEPTIONS
       CNTL_ERROR           = 1
       ERROR_NO_GUI         = 2
       WRONG_PARAMETER      = 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.
    the return parameter will be "X" if file exists else it will be blank.
    Cheers

  • Acrobat Reader won't read pdfs: "file path not valid"

    I thought that my PlayBook would be the perfect device to read pdfs in the Adobe Reader. The only problem is when I download a pdf from the internet, or copy a pdf from my computer, and click on the file icon from within the Reader, all I get is a cryptic error message that reads "The file path is not valid". No hints at what to do.
    At first I thought it was a problem with the file. But every file suffers from the same ill fate. Do you have any suggestions?

    Article ID: KB26744
    Unable to open any PDF documents on BlackBerry PlayBook
    Type: Support Content
    Last Modified: 06-17-2011
    Product(s) Affected:
        BlackBerry® PlayBook™
    Overview
    When attempting to open locally saved or attached Adobe® PDF document the following error is returned:
    The file path is not valid
    Environment
        BlackBerry® PlayBook™ tablet
    Cause
    The error is returned due to application permissions to of the Adobe® Reader application on the BlackBerry® Playbook™. The 'files' option within Adobe Reader application is set to 'Denied'.
    Resolution
    Edit the application permissions file access rights for the Adobe Reader application.
    1.  On BlackBerry Playbook open Options
    2.  Select Security -> Application Permissions
    3.  Select Adobe Reader application
    4.  Edit file permissions setting to allow the application to access files stored on BlackBerry PlayBook
    5.  Save settings by selecting Back button after making changes
    rabbitupnorth:
    This solution works! Problem solved.

  • Opening PDFs get "file path is not valid" errmsg

    very strange...
    I dumped a bunch of PDFs, word, excel & ppt files onto the documents folder. 
    All the PDFs give me "file path is not valid" errmsg and cannot be opened.
    But the word, excel & ppt files can be opened.
    Can someone help me figure it out? 
    Thanks.
    Solved!
    Go to Solution.

    solution is here: http://forums.crackberry.com/showthread.php?t=607769
    I feel also compelled to mention that I've had a ticket open at rim for this issue since 04/21 and have been escalated numerous times and yet all this time rim support has had no clue how simple the problem is to fix. This solution was posted >2 full days ago.

  • The temporary file path is not valid.  Lightroom cannot start

    Windows XP, SP3, Lightroom 2.5.
    External hard drive starts acting funny.  Round here we expect hard drive failure, so I order a new drive and when it arrives copy the backup onto the new drive.  The new drive has the same drive letter as the old one, but not the same name.  When I try to open a catalog I get: "The temporary file path is not valid.  Lightroom cannot start."  The catalogs seem to be fine, as when I open lightroom directly, not by clicking the .lrcat file, catalogs look normal.  If I copy the lrcat file to my internal hard drive it opens.  If I create a new catalog on the external drive I get the same problem.
    I have tried deleting the preferences file.  I have tried deleteing and reinstalling lightroom.  I have used the external HD on another computer with lightroom and it opens normally.
    All I can imagine is that there is some setting, somewhere in the registry which does not get erased when the lightroom gets re-installed.  Any guesses?
    I am at a loss!  Please hope me!

    Could be your Windows tempfile path is messed up. You could try going to Control Panel/Advanced and pushing the Environment Variables button.See what the TEMP and TMP variables are set to.
    Under "User Variables", both of mine are set to C:\Documents and Settings\<my name>\Local Settings\Temp.
    Under "System Variables", both are set to C:\Windows\Temp.
    Make sure that the directories referred to are legal and on accessible drives. Make sure they aren't read-only. It wouldn't hurt to create them if they don't exist.
    It's worth a try, I think.
    Hal

  • Archos 7: the file path is not valid

    Hi,
    I installed Adobe Readwe on my Archos 7 Tablet (Android 2.1).
    Every time I try to open a file the message "the file path is not valid" shows.
    Could you please help me ?
    Regards
    Konstantin Tzovanis

    Hey,
    I'm having the same problem.
    I just recently downloaded and installed the Acrobat Reader on my Archos 7 (home tablet). The installation run without any problems. But whenever I try to open a PDF file, a message shows up, telling me "Error: The file path is not valid".
    I have tried almost every single folder on my tablet. Does the PDF file need a specific file name? Do I have to create a folder (what would be it's name)?
    I haven't tried to download PDFs from the internet... it might work, but it would be great, if I can copy some PDFs from my computer to my tablet, too.
    Please Help!
    Thanks
    Matt

  • Lightroom wont start says tempoary file path not valid

    Believe this is due to an (windows 7) update.Says Lightroom cannot operate without a valid temporary file path.

    Go to the new folder location for Lightroom
    Find Lightroom.exe
    Right click Lightroom.exe
    select make "new short cut".
    drag shortcut file to desktop
    delete old LR icon
    rename shortcut you just created to what ever you want by right clicking icon and selecting rename.
    You should be good to go.
    Jim

  • Validation and F4 help on an application server file path parameter

    Hi
    I have a field on a selection screen called File Path and it is for a download program where the user needs to specify the path for the download (NOT THE ACTUAL FILENAME).
    I am trying to find a function or method that allows a user to use F4 help to browse for a directory rather than a specific file. There are lots of posts out there asking this question but all of the answers point to functions that allow you to browse for a particular file rather than just the file path/directory.
    Does anyone know of a function that provides F4 help to browse for a file path on the Server (NOT PC). I would want the user to just be able to select the directory or path and have the path returned. They should not need to pick a specific file.
    F4_DXFILENAME_TOPRECURSION is a very good function but unfortunately it makes the user pick a file rather than just a directory.
    In addition to this, does anyone know of a function or method that allows you to then validate the path\directory that is entered?
    Thanks for your help
    Nicole

    Hi,
      You can try with the FM 'EPS_GET_DIRECTORY_LISTING'. With this Fm module you will get you the list of files of a particular path in an internal table. Then you can populate this internal table in F4 help.
    Hope this solves your problem. If any difficulty, come back to me about that.
    Below are some other FM related to application server directory. Hope these Helps.
    EPS_GET_DIRECTORY_LISTING
    EPS_GET_DIRECTORY_PATH
    EPS_GET_FILE_ATTRIBUTES
    EPS_GET_FTP_SYSTEM_INFO
    Regards,
    Shailesh Jadhav

  • File path of open data storage

    Hello all!
    Now I'm using the blocks of open data storage, write data and close data storage for storing and extracting result data. For the file path issue, before I
    set the data path by double clicking the "open data storage" block and inserting the file location in the indicated place, and that worked!
    Now since I made a stand alone application of this program and shall use it in other computers, the file location I inserted in open data storage block isn't
    valid any more in other PCs. So I modified my source code by connecting a "current vi path" to the open data storage block's file path node instead of
    inserting it inside the block, and this doesn't work! During running there shows an error in the write data block saying that the storage refnum isn't valid!
    I'm wondering why I couldn't specify the file path like this. Any way to allow me to specify the file path as the current vi path?
    Thanks!
    Chao
    Solved!
    Go to Solution.

    You need to account for the path changes when built in to an application, have a look at this example.
    https://decibel.ni.com/content/docs/DOC-4212
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • How to set the File Path to run a javascript using Plugin Code?

    Hi All,
    Im new to Indesign Plugin Development.Can any one help me out with my problem.
    What i want to do is to run a javascript using Plugin Code.When i went through this forum i was able to find out that i should use the IscriptRunner Class to automate this.I could also figure out that the Member Function to use is "CanHandleFile" &"RunFile".
    The first parameter in CanHandleFile & RunFile Member Function is to specify the path of the JavaScript File i suppose!I could also find out that IDFile has to used to set the file path Information.
    But im clueless how to set the Javascript FilePath using IDFile.Can any one help me how to do this?Any Code Snippets Please?
    Waiting for reply.
    Thanks
    myRiaz

    Hi,  Andreas<br /><br />  Can you explain this in detail? I found it in your post before.<br /><br />  The content of elements are returned through the Characters callback function:<br /><br />From ISaxContentHandler.h:<br /><br />/**<br />        Receives character data<br /><br />The parser will call this method to report each chunk of<br />        character data. SAX parsers may return all contiguous<br />        character data in a single chunk, or they may split it into<br />        several chunks. But all characters in any single<br />        event must come from the same external entity so the<br />        Locator provides useful information.<br /><br />Note some parsers will report whitespace using the<br />        IgnorableWhitespace() method rather than this one (validating<br />        parsers must do so).<br /><br />@param Chars The characters from the XML document.<br />        */<br />virtual void Characters(const PMString& chars) = 0; <br /><br />  What i have done is implement my own SAXContentHandlerServiceBoss, and in my file XXXSAXContentHandler.cpp, I override the fonctions StartElement, EndElement, and Characters() like below: I add the PMString xmlData to collect the file content:<br /><br />class XXXSAXContentHandler : public CSAXContentHandler<br />{<br />void XXXSAXContentHandler::Characters(const WideString& chars)<br />{<br />xmlData.Append(chars);<br />}<br /><br />void XXXSAXContentHandler::StartElement(const WideString& uri, const WideString& localname, const WideString& qname, ISAXAttributes* attrs)<br />{<br />xmlData.Append("<"); xmlData.Append(localname); xmlData.Append(">");<br />}<br />void XXXSAXContentHandler::EndElement(const WideString& uri, const WideString& localname, const WideString& qname)<br />{<br />xmlData.Append("</"); xmlData.Append(localname); xmlData.Append(">");<br />}<br /><br />}<br /><br />and in my program, I use the code below to call the fonction I overrided, but I dont know how I can get the String xmlData I defined in the XXXSAXContentHandler.cpp<br /><br />InterfacePtr<IK2ServiceRegistry> serviceRegistry(gSession, UseDefaultIID());<br /><br />InterfacePtr<IK2ServiceProvider> xmlProvider(serviceRegistry->QueryServiceProviderByClassID(kXMLParserService, kXMLParserServiceBoss));<br /><br />InterfacePtr<ISAXServices> saxServices(xmlProvider, UseDefaultIID());<br />InterfacePtr<ISAXContentHandler> saxHandler(::CreateObject2<ISAXContentHandler>(kXXXSAXContentHandlerServiceBoss));<br />saxHandler->Register(saxServices);<br />bool16 parseFailed = saxServices->ParseStream(readStream, saxHandler);<br /><br />Can you give me any help?<br /><br />Thanks and regards!

  • Difference between logical file path and physical file path

    Hi,
    Can anyone tell me why logical file path is required and why physical file path is required? What exactly is the difference bet them?
    Thanks in advance.
    Regards,
    PS.

    Hi,
    The function module FILE_GET_NAME convert a logical path into its corresponding physical path.
    The advantage of using logical pathes within your applications is obivous:
    If you need to change the physical path you just adjust it within transaction FILE yet no changes are required to your application.
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/25/ab3a57df3b11d189fc0000e829fbbd/frameset.htm
    The file names that you use in ABAP statements for processing files are physical names. This means that they must be syntactically correct filenames for the operating system under which your R/3 System is running. Once you have created a file from an ABAP program with a particular name and path, you can find the same file using the same name and path at operating system level.
    Since the naming conventions for files and paths differ from operating system to operating system, ABAP programs are only portable from one operating system to another if you use the tools described below.
    To make programs portable, the R/3 System has a concept of logical filenames and paths. These are linked to physical files and paths. The links are created in special tables, which you can maintain according to your own requirements. In an ABAP program, you can then use the function module FILE_GET_NAME to generate a physical filename from a logical one.
    Maintaining platform-independent filenames is part of Customizing. For a full description, choose Tools ® Business Engineer ® Customizing, followed by
    Implement. projects ® SAP Reference IMG. On the next screen, choose Basis Components System Administration ® Platform-independent File Names.
    For a more detailed description of the function module FILE_GET_NAME, enter its name on the initial screen of the Function Builder and choose Goto Documentation. On the next screen, choose Function module doc.
    Another way of maintaining platform-independent filenames is to use the Transaction FILE. The following sections provide an overview of the transaction.
    To create a logical filename, choose Logical filename definition, client-independent from the Navigation group box in Transaction FILE, then choose New entries. You define logical filenames
    You can either define a logical filename and link it to a logical path (as displayed here), or you can enter the full physical filename in the Physical file field. In the latter case, the logical filename is only valid for one operating system. The rules for entering the complete physical filename are the same as for the definition of the physical path for the logical file. To display further information and a list of reserved words, choose Help.
    If you link a logical path to a logical file, the logical file is valid for all syntax groups that have been maintained for that logical path. The filename specified under Physical file replaces the reserved word  in the physical paths that are assigned to the logical path. To make the name independent of the operating system, use names that begin with a letter, contain up to 8 letters, and do not contain special characters.
    Save your changes.
    regards,
    Omkar.

  • Diff between logical and physical file path

    Hi ,
    Could you please explain difference between logical and physical file path's and their importance in ABAP.
    Thanks and regards,
    shyla

    Hi
    The function module FILE_GET_NAME convert a logical path into its corresponding physical path.
    The advantage of using logical pathes within your applications is obivous:
    If you need to change the physical path you just adjust it within transaction FILE yet no changes are required to your application.
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/25/ab3a57df3b11d189fc0000e829fbbd/frameset.htm
    The file names that you use in ABAP statements for processing files are physical names. This means that they must be syntactically correct filenames for the operating system under which your R/3 System is running. Once you have created a file from an ABAP program with a particular name and path, you can find the same file using the same name and path at operating system level.
    Since the naming conventions for files and paths differ from operating system to operating system, ABAP programs are only portable from one operating system to another if you use the tools described below.
    To make programs portable, the R/3 System has a concept of logical filenames and paths. These are linked to physical files and paths. The links are created in special tables, which you can maintain according to your own requirements. In an ABAP program, you can then use the function module FILE_GET_NAME to generate a physical filename from a logical one.
    Maintaining platform-independent filenames is part of Customizing. For a full description, choose Tools ® Business Engineer ® Customizing, followed by
    Implement. projects ® SAP Reference IMG. On the next screen, choose Basis Components System Administration ® Platform-independent File Names.
    For a more detailed description of the function module FILE_GET_NAME, enter its name on the initial screen of the Function Builder and choose Goto Documentation. On the next screen, choose Function module doc.
    Another way of maintaining platform-independent filenames is to use the Transaction FILE. The following sections provide an overview of the transaction.
    To create a logical filename, choose Logical filename definition, client-independent from the Navigation group box in Transaction FILE, then choose New entries. You define logical filenames
    You can either define a logical filename and link it to a logical path (as displayed here), or you can enter the full physical filename in the Physical file field. In the latter case, the logical filename is only valid for one operating system. The rules for entering the complete physical filename are the same as for the definition of the physical path for the logical file. To display further information and a list of reserved words, choose Help.
    If you link a logical path to a logical file, the logical file is valid for all syntax groups that have been maintained for that logical path. The filename specified under Physical file replaces the reserved word  in the physical paths that are assigned to the logical path. To make the name independent of the operating system, use names that begin with a letter, contain up to 8 letters, and do not contain special characters.
    Save your changes.

Maybe you are looking for