Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Validate Path ?

Former Member
0 Kudos

Hi,

my reqmnt is i want to validate a file path provided by the user in the selection screen.I want to check whether that particular file path is present in Application server or not. How to achieve this is ther any class or FM which will help me in achieving this result ?

regards,

Navneeth.K

1 ACCEPTED SOLUTION

Former Member
0 Kudos

try the statement

OPEN DATASET p_filename FOR INPUT IN TEXT MODE.

if sy-subrc = 8.
message 'file not found' type i.
endif.

4 REPLIES 4

Former Member
0 Kudos

try the statement

OPEN DATASET p_filename FOR INPUT IN TEXT MODE.

if sy-subrc = 8.
message 'file not found' type i.
endif.

Former Member
0 Kudos

You can give the search help of the application server file.Then u dont have to do any explicit validetion...

You can refer to below code to get the F4 help for application server:

PARAMETERS:  p_phys  RADIOBUTTON GROUP g1.                  " appln server file

PARAMETERS: p_ifile  TYPE   dxfile-filename LOWER CASE.

*---------------------------------------------------------------------
* AT SELECTION SCREEN ON VALUE REQUEST
*---------------------------------------------------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ifile.
  PERFORM help_input_file USING p_locl CHANGING p_ifile.

___________________________________________________

FORM help_input_file  USING    p_phys_file   TYPE c

                      CHANGING p_source_path TYPE any.

    CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
      EXPORTING
        dynpfield_filename = 'P_IFILE'
        dyname             = sy-repid
        dynumb             = sy-dynnr
        filetype           = 'P'
        location           = 'A'.


ENDFORM.                    " help_input_file

Former Member
0 Kudos

Hi Navaneet

please check this FM <b>DX_FILE_EXISTENCE_CHECK</b>.

To validate the path

Just check these links

Regards Rk

Former Member
0 Kudos

Hi Navneeth ,

Try this.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS:file LIKE rlgrap-filename .

SELECTION-SCREEN END OF BLOCK b1.

DATA: v_file_name TYPE string,

v_file_name = file.

CALL METHOD cl_gui_frontend_services=>file_exist

EXPORTING

file = v_file_name

RECEIVING

result = v_return

EXCEPTIONS

cntl_error = 1

error_no_gui = 2

wrong_parameter = 3

not_supported_by_gui = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE a000 WITH v_file_name text-001.(Specify valid file path)

EXIT.

ENDIF.

IF v_return IS INITIAL.

MESSAGE a000 WITH v_file_name text-002.("Invalid Filename ")

ENDIF.

Regards

Avi....