18 Replies Latest reply: Aug 20, 2009 9:33 AM by Guest RSS

how can i validate a path

Carlos Venturo
Currently Being Moderated

hi experts,

 

how can i validate a path... i tried to use cl_gui_frontend_services=>directory_exist

but it gives me an error

 

for a local path and an app server path??

 

thx in advance

  • Re: how can i validate a path
    Sastry Gunturi
    Currently Being Moderated

    cl_gui_frontend_services=>directory_exist is for checking directories (not files) on the presentation server ( on local pc, laptop)... You cannot use it for validating path on App server. For App server you need to use open dataset... read dataset. etc...

     

    Edited by: Karthik on Aug 20, 2009 2:21 AM

  • Re: how can i validate a path
    Chandra Indukuri
    Currently Being Moderated

    you can use CL_GUI_FRONTEND_SERVICES=>FILE_EXIST to check for file on the desktop.

     

    for the App server use Open dataset. If it fails then there is no file at the specified location.

  • Re: how can i validate a path
    Currently Being Moderated

    hi Carlos Venturo,

     

    use the method

     

    file_exist from the class cl_gui_frontend_services...

    this will return you wether you have the file on the specified path or not...

     

    You can use method CL_GUI_FRONTEND_SERVICES=>FILE_EXIST

     

    Or you can also refer FM's:

     

    CONV_UTIL_CHECK_FILE_EXISTENCE

    CV120_DOC_FILE_EXISTENCE_CHECK

    CV122_DOC_FILE_EXISTENCE_CHECK

    DX_FILE_EXISTENCE_CHECK

    PFL_CHECK_OS_FILE_EXISTENCE

     

    Or when you simply upload a file using any FM, just check sy-subrc.

    If not equal to 0, then display message Invalid Directory or File Name.

     

    Hope this helps you.

     

    -Thanks & Regards

     

    Saurabh Goel

  • Re: how can i validate a path
    Nidhi Kothiyal
    Currently Being Moderated

    Hi Carlos,

     

    Go through this link, I hope your problem will be solved.

     

    How to validate a mentioned file path?

     

    Regards,

    Nidhi Kothiyal

    • Re: how can i validate a path
      Currently Being Moderated

      cl_GUI_FROMENT_services

      from the name itself its says its from front end only. so it doesnt checks app server path.

       

      now. directory_exist from the name it checks directory.

      so need fle_exist for a file in presentation server.

       

      and for a path in app server use OPEN DATASET and read dataset.

       

      Edited by: soumya prakash mishra on Aug 20, 2009 10:24 AM

  • Re: how can i validate a path
    Carlos Venturo
    Currently Being Moderated

    please guys read carefully .. i nver said validate files ...

    • Re: how can i validate a path
      Nitwick !
      Currently Being Moderated

      Hi,

       

      You could use the FM to find the file path. See if this of some to you

       

      
      parameters: p_fname type string.
      data: GV_FPATH TYPE FILEEXTERN.
                          
      
      CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
        EXPORTING
         CLIENT                           = SY-MANDT
          logical_path                     = 'HOME'
      *   OPERATING_SYSTEM                 = SY-OPSYS
      *   PARAMETER_1                      = ' '
      *   PARAMETER_2                      = ' '
      *   PARAMETER_3                      = ' '
      *   USE_BUFFER                       = ' '
          file_name                        = P_FNAME
      *   USE_PRESENTATION_SERVER          = ' '
      *   ELEMINATE_BLANKS                 = 'X'
       IMPORTING
         FILE_NAME_WITH_PATH              = GV_FPATH
       EXCEPTIONS
         PATH_NOT_FOUND                   = 1
         MISSING_PARAMETER                = 2
         OPERATING_SYSTEM_NOT_FOUND       = 3
         FILE_SYSTEM_NOT_FOUND            = 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.
      
      WRITE:/ 'File Path:',GV_FPATH.
      

       

    • Re: how can i validate a path
      Currently Being Moderated

      where is your file? presentation server or app server?

  • Re: how can i validate a path
    tutun nandy
    Currently Being Moderated

    Hi Carlos,

     

    you follow the below coding, where you will get to separate validation

    for presentation server & application server file path.

     

    FORM present_validation .

      DATA: lw_check TYPE c,

            lw_file TYPE string.

     

      IF po_psv IS INITIAL.

        IF sy-ucomm = 'ONLI' OR sy-ucomm = space.

          MESSAGE  'Please input the file name' TYPE lc_e.

        ENDIF.

      ELSE.

        lw_file = po_psv.

        lw_check = cl_gui_frontend_services=>file_exist( lw_file ).

        IF lw_check IS INITIAL.

          MESSAGE  'Please input the correct file path' TYPE lc_e.

        ENDIF.

      ENDIF.

     

    ENDFORM.                    " PRESENT_VALIDATION

     

     

    FORM application_validation .

     

      DATA: lw_file TYPE string.

      lw_file = po_asv.

     

      IF po_asv IS INITIAL.

        IF sy-ucomm = 'ONLI' OR sy-ucomm = space.

          MESSAGE  'Please input the file name' TYPE lc_e.

        ENDIF.

      ELSE.

        OPEN DATASET lw_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

        IF sy-subrc NE 0.

          MESSAGE  'Please input the correct file path' TYPE lc_e.

        ENDIF.

      ENDIF.

     

    ENDFORM.                    " APPLICATION_VALIDATION

     

    Hope this can solve your problems.

     

    Regards,

    Tutun

  • Re: how can i validate a path
    Aditi Wason
    Currently Being Moderated

    Hi Carlos,

    I suggest you to go through the below link .

     

    I guess there are few methods that you can chose to solve your problem.

     

    FM to validate file path on app server .

     

    Hope this helps you .

     

    Thanks and Regards .

     

    Aditi Wason.

  • Re: how can i validate a path
    Rainer Hübenthal
    Currently Being Moderated

    Is there a \ or a / at the end of your path?

     

    Maybe

     

    c:\xyz\wherever\whatever

     

    is treated as a file. So please check if your path ends with one ofdof the path delimters and check with

     

    c:\xyz\wherever\whatever\

     

    again

  • Re: how can i validate a path
    Shweta Joon
    Currently Being Moderated

    hii carlos,

     

    for validation of path on application server

     

    use fm EPS_GET_DIRECTORY_LISTING

     

    Second use FM PFL_CHECK_OS_FILE_EXISTENCE which perfectly working fine for application server file validation. Here also file name is case sensitive. Check this FM in SE37 by giving ur file name and check the check box Lower case

     

    rgrds,

    shweta

     

    Edited by: Shweta Joon on Aug 20, 2009 8:01 AM

  • Re: how can i validate a path
    Carlos Venturo
    Currently Being Moderated

    thx for the answer ... but PLEASE read at least the first post.. i'm looking for another way to valdiate because the FM cl_gui_frontend_services=>directory_exist gives me an error!!! it says there is no method (probably because its an old version).. because its works fine in another server...but in the one im programming it doesnt

     

    thx

Actions