2014 Oct 07 10:06 AM
Hi All
I have a peculiar problem and not sure how to solve it. I have two file download paths
1> Rad1 : download in presentation server
2> Rad2 : Download in application server
Now I am asked to add file path validation.. The code I have used is below.. But what happens if when a user provides a wrong path on one of them , then he cannot change to the other radio button,as the file path is disabled and directly throws the error.
How can I makethis toggle of radiobutton work . I have also used loop at screen above these events
AT SELECTION-SCREEN ON p_pres.
PERFORM f_validate_file_path USING p_pres. "validate file path
AT SELECTION-SCREEN ON p_apps.
PERFORM f_validate_apps_filepath USING p_apps.
FORM f_validate_file_path USING fp_file TYPE text150.
DATA : lv_dir TYPE string,
lv_file TYPE string,
lv_result(1) TYPE c.
DATA : lv_filename TYPE string.
lv_filename = fp_file.
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = fp_file
IMPORTING
stripped_name = lv_file "file name
file_path = lv_dir "directory path
EXCEPTIONS
x_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
" check existence of directory
CALL METHOD cl_gui_frontend_services=>directory_exist
EXPORTING
directory = lv_dir
RECEIVING
result = lv_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF lv_result IS INITIAL. "lv_result is X if valid directory
MESSAGE 'Invalid Directory' TYPE 'E'.
ENDIF.
endform.
*----------------------------------------------------------------------*
FORM f_file_validate USING fp_file TYPE char128
fp_subrc TYPE sy-subrc.
DATA: l_exist(1).
CALL FUNCTION 'DX_FILE_EXISTENCE_CHECK'
EXPORTING
filename = fp_file
pc = c_x "if space then check is made in application
*server else in presentation server
IMPORTING
file_exists = l_exist.
IF l_exist NE c_x.
fp_subrc = 8.
ENDIF.
Hi All
I have a peculiar problem and not sure how to solve it. I have two file download paths
1> Rad1 : download in presentation server
2> Rad2 : Download in application server
Now I am asked to add file path validation.. The code I have used is below.. But what happens if when a user provides a wrong path on one of them , then he cannot change to the other radio button,as the file path is disabled and directly throws the error.
How can I makethis toggle of radiobutton work . I have also used loop at screen above these events
AT SELECTION-SCREEN ON p_pres.
PERFORM f_validate_file_path USING p_pres. "validate file path
AT SELECTION-SCREEN ON p_apps.
PERFORM f_validate_apps_filepath USING p_apps.
FORM f_validate_file_path USING fp_file TYPE text150.
DATA : lv_dir TYPE string,
lv_file TYPE string,
lv_result(1) TYPE c.
DATA : lv_filename TYPE string.
lv_filename = fp_file.
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = fp_file
IMPORTING
stripped_name = lv_file "file name
file_path = lv_dir "directory path
EXCEPTIONS
x_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
" check existence of directory
CALL METHOD cl_gui_frontend_services=>directory_exist
EXPORTING
directory = lv_dir
RECEIVING
result = lv_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF lv_result IS INITIAL. "lv_result is X if valid directory
MESSAGE 'Invalid Directory' TYPE 'E'.
ENDIF.
endform.
*----------------------------------------------------------------------*
FORM f_file_validate USING fp_file TYPE char128
fp_subrc TYPE sy-subrc.
DATA: l_exist(1).
CALL FUNCTION 'DX_FILE_EXISTENCE_CHECK'
EXPORTING
filename = fp_file
pc = c_x "if space then check is made in application
*server else in presentation server
IMPORTING
file_exists = l_exist.
IF l_exist NE c_x.
fp_subrc = 8.
ENDIF.
2014 Oct 07 10:33 AM
Use a message type different than 'E'. Or you can pop up error message as below -
MESSAGE 'Invalid Directory' TYPE 'I' DISPLAY LIKE 'E'.
Best Regards
Abhinab