<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to validate file path in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694216#M1577254</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use can use the folowing approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Get the file name using&lt;/P&gt;&lt;P&gt;   -  CALL FUNCTION 'F4_FILENAME' or &lt;/P&gt;&lt;P&gt;   - CL_GUI_FRONTEND_SERVICES-&amp;gt;GUI_UPLOAD&lt;/P&gt;&lt;P&gt;2. Validate the file path - pass the file name found in step 1 above&lt;/P&gt;&lt;P&gt;  -     CALL METHOD cl_gui_frontend_services=&amp;gt;file_exist&lt;/P&gt;&lt;P&gt;      EXPORTING&lt;/P&gt;&lt;P&gt;        file   = lv_file&lt;/P&gt;&lt;P&gt;      RECEIVING&lt;/P&gt;&lt;P&gt;        result = lv_result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF lv_result NE c_x.&lt;/P&gt;&lt;P&gt;      MESSAGE e114(zzsam). " Invalid file name entered. Display error message.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Feb 2011 08:45:30 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-02-03T08:45:30Z</dc:date>
    <item>
      <title>How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694209#M1577247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have field on my selection screen to enter file path. This parameter has F4 help to choose the file path. However, I have a concern over here...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If user enters file path manually(meaning that without using F4), there is chance that he may enter file path without any extension or without any drive/or the file which doesn't exist in the system ...In this case I want to validate the file path. And I should give an error saying "Invalid file path or name".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please help me out with any FM or any other go for the same?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sandeep&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 05:26:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694209#M1577247</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-03T05:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694210#M1577248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Sandeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just hard code that and make as default.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Madhu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 05:32:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694210#M1577248</guid>
      <dc:creator>madhu_vadlamani</dc:creator>
      <dc:date>2011-02-03T05:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694211#M1577249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it about validating in Application Server ? If yes, check the method OPEN in class CL_RSAN_UT_APPSERV_FILE_READER. Method returns sy-subrc 1 if there is an error in opening the specified file name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is validation from GUI, check the methods "DIRECTORY_EXIST" and "FILE_EXIST" in class CL_GUI_FRONTEND_SERVICES.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 05:36:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694211#M1577249</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-03T05:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694212#M1577250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sandeep Reddy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    To validate the file path use the Function module&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                &lt;STRONG&gt;CV120_DOC_FILE_EXISTENCE_CHECK&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It will check whether the file path you entered in the parameter &lt;STRONG&gt;PF_FILE&lt;/STRONG&gt; exists or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Phani Kumar M&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 05:45:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694212#M1577250</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-03T05:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694213#M1577251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need to validate only the extension, you can do like the following code. Hopefully you must know the extension of the file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  filelen = strlen( filepath ).&lt;/P&gt;&lt;P&gt;  filelen = filelen - 4 .&lt;/P&gt;&lt;P&gt;  file_extn = filepath+filelen.&lt;/P&gt;&lt;P&gt;  translate file_extn to upper case.&lt;/P&gt;&lt;P&gt;  if file_extn ne '.csv'.&lt;/P&gt;&lt;P&gt;    message 'Invalid file format.File extension should be '.CSV''.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Karthi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 06:15:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694213#M1577251</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-03T06:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694214#M1577252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If its an application server simply you can check this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;open dataset d1........&lt;/P&gt;&lt;P&gt;if sy-subrc  0.&lt;/P&gt;&lt;P&gt;write:/ 'File path not found'.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If sy-subrc is zero, it means no file exists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else you can use a function module&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FILE_GET_NAME_USING_PATH&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;Uttam Agrawal&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.abapmadeeasy.com" target="test_blank"&gt;http://www.abapmadeeasy.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: uttamagrawal on Feb 22, 2011 9:22 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 07:17:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694214#M1577252</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-03T07:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694215#M1577253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Sandeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try the following approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. In the declaration part of the parameter in Selection-screen, hard code the directory name, say 'C:\temp\'.&lt;/P&gt;&lt;P&gt;     PARAMETERS: p_file TYPE localfile DEFAULT 'C:\temp\'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Event: AT SELECTION-SCREEN OUTPUT.&lt;/P&gt;&lt;P&gt;    Set the parameter to input disabled (Screen-input = 0). This way the user will not be able to manually change the value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Event: AT SELECTION-SCREEN ON VALUE-REQUEST FOR &amp;lt;parameter_name&amp;gt;, make use of the method 'File_open_dialog' of the class 'CL_GUI_FRONTEND_SERVICES' to read the filename. Once you have the file name, you need to update the same on the screen. So make use of this function module, DYNP_VALUES_UPDATE. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you find this useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers!!!&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Amit Kumar Singh on Feb 3, 2011 9:20 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 08:19:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694215#M1577253</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-03T08:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694216#M1577254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use can use the folowing approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Get the file name using&lt;/P&gt;&lt;P&gt;   -  CALL FUNCTION 'F4_FILENAME' or &lt;/P&gt;&lt;P&gt;   - CL_GUI_FRONTEND_SERVICES-&amp;gt;GUI_UPLOAD&lt;/P&gt;&lt;P&gt;2. Validate the file path - pass the file name found in step 1 above&lt;/P&gt;&lt;P&gt;  -     CALL METHOD cl_gui_frontend_services=&amp;gt;file_exist&lt;/P&gt;&lt;P&gt;      EXPORTING&lt;/P&gt;&lt;P&gt;        file   = lv_file&lt;/P&gt;&lt;P&gt;      RECEIVING&lt;/P&gt;&lt;P&gt;        result = lv_result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF lv_result NE c_x.&lt;/P&gt;&lt;P&gt;      MESSAGE e114(zzsam). " Invalid file name entered. Display error message.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 08:45:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694216#M1577254</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-03T08:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694217#M1577255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the Method  DIRECTORY_EXIST in class CL_GUI_FRONTEND_SERVICES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After the POP UP use this method. If the sy-subrc is zero then the filepath exists other wise no.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With Regards,&lt;/P&gt;&lt;P&gt;Sumodh.P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 08:46:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694217#M1577255</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-03T08:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694218#M1577256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI &lt;/P&gt;&lt;P&gt; For the presentation server first you have to split the path entered into directory and file.You can used FM SO_SPLIT_FILE_AND_PATH for this purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you can validate the directory and file independently using cl_gui_frontend_services=&amp;gt;directory_exist  &amp;amp;  cl_gui_frontend_services=&amp;gt;file_exist&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*--FM to split File Path into Directory and File Name
  CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
    EXPORTING
      full_name     = v_fname
    IMPORTING
      stripped_name = v_file
      file_path     = v_dir
    EXCEPTIONS
      x_error       = 1
      OTHERS        = 2.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*--Method to Validate Directory
    CALL METHOD cl_gui_frontend_services=&amp;gt;directory_exist
      EXPORTING
        directory            = v_dir
      RECEIVING
        result               = lv_res
      EXCEPTIONS
        cntl_error           = 1
        error_no_gui         = 2
        wrong_parameter      = 3
        not_supported_by_gui = 4
        OTHERS               = 5.

    IF lv_res IS INITIAL.
      MESSAGE e000 WITH 'Directory does not exist'(010).
    ELSE.
      CLEAR lv_res.
*--Method to Validate File
      CALL METHOD cl_gui_frontend_services=&amp;gt;file_exist
        EXPORTING
          file                 = v_file
        RECEIVING
          result               = lv_res
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          wrong_parameter      = 3
          not_supported_by_gui = 4
          OTHERS               = 5.

      IF lv_res IS INITIAL.
        MESSAGE e000 WITH 'File does not exist'(009).
      ENDIF.
    ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Application server you have to use open dataset only&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;OPEN DATASET v_fname FOR INPUT
                          IN TEXT MODE
                          ENCODING DEFAULT
                          IGNORING CONVERSION ERRORS.
    IF sy-subrc = 8.
      MESSAGE e000 WITH 'Invalid Directory or Filename'(015).
    ELSE.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rahuljn on Feb 3, 2011 3:27 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 09:32:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694218#M1577256</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-03T09:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate file path</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694219#M1577257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sandeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wy dont you search in SCN before posting. This has been discussed many times.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 11:03:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-validate-file-path/m-p/7694219#M1577257</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-02-03T11:03:47Z</dc:date>
    </item>
  </channel>
</rss>

