Skip to Content

how do i verify if a directory exists?

how do i verify if a directory exists on unix server(al11)?

for e.g /interfaces/fichiers/IS007/in/file1

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 08:21 AM

    Hi,

    Please try using below statement:

      DATA: lv_dirname(75)     TYPE c,   " name of directory.
            lv_genericname(75) TYPE c,   " name of entry. (may end with *)
            lv_errno(3)    TYPE c,
            lv_errmsg(40)  TYPE c,
    
    CALL 'C_DIR_READ_START' ID 'DIR'    FIELD lv_dirname "<--- Directory Name
                            ID 'FILE'   FIELD lv_genericname
                            ID 'ERRNO'  FIELD lv_errno   "<--- Returns Error Name
                            ID 'ERRMSG' FIELD lv_errmsg. "<--- Returns Error Message
    

    Kind Regards

    Eswar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 21, 2008 at 08:25 AM

    FORM validate_path .

    DATA: v_result TYPE c,

    v_path TYPE string.

    IF p_path+0(1) NE '/'.

    MOVE p_path+0(3) TO v_path.

    • Call the ethod to validate the directory in the presentation server

    CALL METHOD cl_gui_frontend_services=>directory_exist

    EXPORTING

    directory = v_path

    RECEIVING

    result = v_result

    EXCEPTIONS

    wrong_parameter = 3

    OTHERS = 4.

    IF sy-subrc <> 0.

    MESSAGE e004 WITH text-e10. " Please Enter the File Path

    ELSE.

    IF v_result IS INITIAL.

    MESSAGE e004 WITH text-e18. " Please Enter a Valid Path

    ENDIF.

    ENDIF.

    ENDIF.

    ENDFORM.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 21, 2008 at 08:15 AM

    Hi,

    use the method

    CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXIST

    Regards,

    Nagaraj

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.