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

Regarding Validating the Filename for App Server and Presentation Server

Former Member
0 Likes
574

Hi

I have a paramater which will take the input from the user for Filename.

Using this filename if the user clicks the radio button for uploading to app server this will be done or if he clicks the radio button for presentation server it will be downloaded to the local system .

How can i perform the validation for filename here so that if the app server it should start with a /

and if it is for a presentation server it should be according to the windows file format.

Hi

I have a paramater which will take the input from the user for Filename.

Using this filename if the user clicks the radio button for uploading to app server this will be done or if he clicks the radio button for presentation server it will be downloaded to the local system .

How can i perform the validation for filename here so that if the app server it should start with a /

and if it is for a presentation server it should be according to the windows file format.

3 REPLIES 3
Read only

andreas_mann3
Active Contributor
0 Likes
537

hi,

if pc = X.

use method CL_GUI_FRONTEND_SERVICES->FILE_EXIST

else. "app-server

...use fm EPS_GET_FILE_ATTRIBUTES

A.

Read only

Former Member
0 Likes
537

Hi Barathi,

Please find the code. I hope it totally full fills your requirement 100%. Reward me with points, if it is helpful.

----


  • SELECTION SCREEN BLOCK *

----


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

SELECTION-SCREEN BEGIN OF LINE.

PARAMETER rb_rad1 RADIOBUTTON GROUP rept DEFAULT 'X' USER-COMMAND rad1.

SELECTION-SCREEN COMMENT 3(29) text-002 FOR FIELD rb_rad1.

PARAMETERS p_local LIKE btch0000-text80 MODIF ID sg1.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETER rb_rad2 RADIOBUTTON GROUP rept .

SELECTION-SCREEN COMMENT 3(29) text-003 FOR FIELD rb_rad1.

PARAMETERS p_logic LIKE btch0000-text80 MODIF ID sg2.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b3.

----


*& AT SELECTION-SCREEN OUPUT *

----


AT SELECTION-SCREEN OUTPUT.

IF rb_rad1 = 'X'.

CLEAR p_logic.

LOOP AT SCREEN.

IF screen-group1 = 'SG2'.

screen-input = '0'.

screen-intensified = '1'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ELSEIF rb_rad2 = 'X'.

CLEAR p_local.

LOOP AT SCREEN.

IF screen-group1 = 'SG1'.

screen-input = '0'.

screen-intensified = '1'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

&----


*&VALUE REQUEST FOR LOCAL FILE NAME *

&----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_local.

  • Perform To Provide List Of Possible Values

PERFORM f4_local_filename USING p_local.

AT SELECTION-SCREEN ON p_local.

IF p_local IS NOT INITIAL.

  • Perform To Validate Local File

PERFORM validate_local_file.

ENDIF.

AT SELECTION-SCREEN ON p_logic.

IF p_logic IS NOT INITIAL.

  • Perform To Validate Logical File

PERFORM validate_logical_file .

ENDIF.

START-OF-SELECTION.

  • To Restrict Blank File Name

IF rb_rad1 = w_true_fg AND

p_local IS INITIAL.

MESSAGE i016(0) WITH 'Please enter file'.

STOP.

ELSEIF rb_rad2 = w_true_fg AND

p_logic IS INITIAL.

MESSAGE i016(0) WITH 'Please enter file'.

STOP.

ENDIF.

IF p_local IS NOT INITIAL.

PERFORM upload_file USING p_local.

ELSEIF p_logic IS NOT INITIAL.

PERFORM read_file USING p_logic.

ENDIF.

Read only

0 Likes
537

Hi Barathi,

This is continution to th previous post.

*&----


**& Form F4_LOCAL_FILENAME

*&----


    • text

*----


    • -->P_P_LOCAL text

*----


FORM f4_local_filename USING p_local_file.

DATA: w_filetable_nm TYPE filetable,

w_rc_in TYPE i,

w_useraction_in TYPE i.

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

window_title = 'File Selection'

CHANGING

file_table = w_filetable_nm

rc = w_rc_in

user_action = w_useraction_in

EXCEPTIONS

file_open_dialog_failed = 1

cntl_error = 2

error_no_gui = 3

not_supported_by_gui = 4

OTHERS = 5.

IF sy-subrc EQ 0 AND

w_rc_in GT 0.

READ TABLE w_filetable_nm INDEX w_rc_in INTO p_local_file.

ENDIF.

ENDFORM. " F4_LOCAL_FILENAME

&----


*& Form VALIDATE_LOCAL_FILE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM validate_local_file .

DATA : w_result_tx TYPE c,

w_file_st TYPE string.

w_file_st = p_local.

CALL METHOD cl_gui_frontend_services=>file_exist

EXPORTING

file = w_file_st

RECEIVING

result = w_result_tx

EXCEPTIONS

cntl_error = 1

error_no_gui = 2

wrong_parameter = 3

not_supported_by_gui = 4

OTHERS = 5.

IF w_result_tx NE w_true_fg.

MESSAGE e088(/gmc/ze) WITH w_file_st.

ENDIF.

ENDFORM. " VALIDATE_LOCAL_FILE

&----


*& Form VALIDATE_LOGICAL_FILE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM validate_logical_file .

DATA: w_file_nm TYPE file_info-filename, "file name in path

w_dirname LIKE epsf-epsdirnam,

w_filemask LIKE epsf-epsfilnam,

w_logic LIKE btch0000-text80,

w_file LIKE btch0000-text80.

DATA: t_filelist TYPE TABLE OF epsfili,

w_filelist TYPE epsfili.

DATA :w_string_ix TYPE i,

w_index_ix TYPE i,

w_count_ix TYPE i,

w_temp_nm(1) TYPE c.

w_string_ix = STRLEN( p_logic ).

DO w_string_ix TIMES.

w_index_ix = sy-index.

w_count_ix = w_string_ix - 1.

w_temp_nm = p_logic+w_count_ix(1).

IF w_temp_nm NE '/'.

CONCATENATE w_temp_nm w_file_nm INTO w_file_nm.

ELSE.

w_dirname = p_logic+0(w_count_ix).

EXIT.

ENDIF.

w_string_ix = w_string_ix - 1.

ENDDO.

w_logic = w_dirname.

w_file = w_file_nm.

CALL FUNCTION 'PFL_CHECK_DIRECTORY'

EXPORTING

directory = w_logic

write_check = 'X'

filname = w_file

EXCEPTIONS

pfl_dir_not_exist = 1

pfl_permission_denied = 2

pfl_cant_build_dataset_name = 3

pfl_file_not_exist = 4

OTHERS = 5.

CASE sy-subrc.

WHEN 1.

MESSAGE i089(/gmc/ze) WITH w_dirname.

STOP.

WHEN 4.

MESSAGE i088(/gmc/ze) WITH w_file_nm.

ENDCASE.

ENDFORM. " VALIDATE_LOGICAL_FILE