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: 

validation of filename

Former Member
0 Kudos

hi,

I have a parameter filename in the selection screen. is there a way where i can ensure that user doesnt enter any special characters in the file name?

thanks in advance.

Neha

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Neha.

You can use SF_SPECIALCHAR_DELETE function.

CALL FUNCTION 'SF_SPECIALCHAR_DELETE'

EXPORTING

with_specialchar = in_file_name

IMPORTING

WITHOUT_SPECIALCHAR = out_file_name

  • EXCEPTIONS

  • RESULT_WORD_EMPTY = 1

  • OTHERS = 2

.

IF in_file_name <> out_file_name.

There is special characters in the file name.

endif.

Regards.

Sayan

5 REPLIES 5

Former Member
0 Kudos

check the method <b>FILE_EXIST</b> of the class <b>CL_GUI_FRONTEND_SERVICES</b>. It checks the existence of the file in the frontend, hope this helps.

former_member200338
Active Contributor
0 Kudos

Hi,

Check this

IF p_file NP '*.xls'.

MESSAGE e000 WITH text-t07.

ENDIF.

You can also use F4_FILENAME to get a popup when f4 is pressed

Regards,

Niyaz

kishorepallapothula
Participant
0 Kudos

Hi Neha,

You can write simple code in AT SELECTION-SCREEN event by giving the special charators. I hope try it.

Reward if useful.

kishore

Former Member
0 Kudos

Hi Neha.

You can use SF_SPECIALCHAR_DELETE function.

CALL FUNCTION 'SF_SPECIALCHAR_DELETE'

EXPORTING

with_specialchar = in_file_name

IMPORTING

WITHOUT_SPECIALCHAR = out_file_name

  • EXCEPTIONS

  • RESULT_WORD_EMPTY = 1

  • OTHERS = 2

.

IF in_file_name <> out_file_name.

There is special characters in the file name.

endif.

Regards.

Sayan

former_member434229
Active Participant
0 Kudos

Use this function to allow user to select a file name from the system.

Consider p_file is the name of the parameter.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_filename = space

def_path = space

mask = ',.,..'

mode = space

title = space

IMPORTING

filename = p_file

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.