Application Development and Automation 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: 
Read only

file name validation on selection screen

Former Member
0 Likes
1,779

hi everybody,

According to requirement selction screen having a file path. If we specify the file location the data is downloaded and stores in the file. How to perfom validation on that file name.

1 ACCEPTED SOLUTION
Read only

amit_khare
Active Contributor
0 Likes
1,220

Use this FM to split file name PC_SPLIT_COMPLETE_FILENAME into filename & extension then check the both as per your requirement.

Regards,

Amit

reward all helpful replies.

hi everybody,

According to requirement selction screen having a file path. If we specify the file location the data is downloaded and stores in the file. How to perfom validation on that file name.

7 REPLIES 7
Read only

Former Member
0 Likes
1,220

Hi,

What kind of validation do you want to perform?

Regards,

Vinodh.

Read only

0 Likes
1,220

the validations are

1. path validations

2. file name validations

Read only

0 Likes
1,220

Hi

try this:

AT SELECTION-SCREEN
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
      EXPORTING
        DIRECTORY                   = PATH
      CHANGING
        FILE_TABLE                  = FILE_TABLE
        COUNT                          = COUNT
      EXCEPTIONS
        CNTL_ERROR                              = 1
        DIRECTORY_LIST_FILES_FAILED = 2
        WRONG_PARAMETER                 = 3
        ERROR_NO_GUI                           = 4
        OTHERS                                       = 5
            .
    IF SY-SUBRC <> 0.
-> Error
    ELSE.
      IF COUNT < 1.
 -> Error
      ENDIF.
    ENDIF.

U can use the method FILE_EXIST for the file

Read only

kiran_k8
Active Contributor
0 Likes
1,220

Aswlkm,

parameter p_filename like rlgrap-filename value 'c:\younus.txt'.

if p_filename is not initial.

call gui_download.

else.

Message e000 with 'the field p_filename can't be initial'.

endif.

the above if condition checks the field p_filename is initial or not,if initital means not given any path it will throw up an error message else will call the gui_upload.

K.Kiran.

Read only

amit_khare
Active Contributor
0 Likes
1,221

Use this FM to split file name PC_SPLIT_COMPLETE_FILENAME into filename & extension then check the both as per your requirement.

Regards,

Amit

reward all helpful replies.

Read only

Former Member
0 Likes
1,220
no need for validation , provide F4 help for that file

data: ifiletable type filetable.
data: xfiletable like line of ifiletable.
data: rc type i.
 
parameters: p_file1 type localfile default'C:test.txt'.
 
at selection-screen on value-request for p_file1.
 
call method cl_gui_frontend_services=>file_open_dialog
   EXPORTING
*    WINDOW_TITLE            =
*    DEFAULT_EXTENSION       =
*    DEFAULT_FILENAME        =
*    FILE_FILTER             =
     INITIAL_DIRECTORY       = 'C:'
*    MULTISELECTION          =
  changing
    file_table              = ifiletable
    rc                      = rc
*    USER_ACTION             =
  EXCEPTIONS
    FILE_OPEN_DIALOG_FAILED = 1
    CNTL_ERROR              = 2
    ERROR_NO_GUI            = 3
    others                  = 4.
        .
 read table ifiletable into xfiletable index 1.
 if sy-subrc = 0.
  p_file1 = xfiletable-FILENAME.
 endif.
Read only

Former Member
0 Likes
1,220

HI u can use these function modules.

1) CV120_SPLIT_PATH

2) RZL_READ_DIR_LOCAL