01-03-2014 5:42 PM
Hi gurus.
I have a program with filed screen to path of save data.
If I type C:/ in this field , he saves my file text1 in C:/
But if I write C:/Test ,He saves in C:/ with file name Testtext1. ( it wrong)
How I can tell if user typed in last caracter '/' or one letter.?
Thanks .
01-03-2014 5:49 PM
Hi,
So the program has defaulted the file name as text in C drive.
Please find the options below!
- If it is customized program, provide the file name is default or
- Validate the program to enter the only path not the file name!
- better to give the F4 functionality to select the file and store the inforamation
01-03-2014 5:49 PM
Hi,
So the program has defaulted the file name as text in C drive.
Please find the options below!
- If it is customized program, provide the file name is default or
- Validate the program to enter the only path not the file name!
- better to give the F4 functionality to select the file and store the inforamation
01-03-2014 5:51 PM
Hi Ronaldo,
Instead of giving path name, you can ask user select the path using F4 help.
Arivazhagan S
01-04-2014 3:49 AM
Hi Ronaldo Aparecido
Try like this
DATA: i_path TYPE string,
sel_path TYPE string,
file_name type string.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .
PARAMETER: p_path TYPE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
initial_folder = i_path
CHANGING
selected_folder = sel_path
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
OTHERS = 3.
IF sy-subrc = 0.
CALL METHOD cl_gui_cfw=>flush( ).
IF sel_path IS NOT INITIAL.
p_path = i_path = sel_path.
ENDIF.
ENDIF.
START-OF-SELECTION.
CONCATENATE i_path '\text1.txt' into file_name.
WRITE : file_name.
01-04-2014 4:19 AM
Hi Ronaldo,
Though I'll suggest to use method mentioned by Ramesh, so that user can directly select the folder, here is another option if you want to put '/' at runtime in File path:
*----------------------------------------------------
SELECTION-SCREEN begin of BLOCK b1.
PARAMETERS p_path TYPE char128.
SELECTION-SCREEN end of BLOCK b1.
START-OF-SELECTION.
data : lv_len TYPE i.
*DESCRIBE FIELD p_path length lv_len IN CHARACTER MODE.
lv_len = strlen( p_path ).
lv_len = lv_len - 1.
IF NOT p_path+lv_len(1) = '/'.
CONCATENATE p_path '/' INTO p_path.
WRITE p_path.
ENDIF.
*----------------------------------------------------
Warm Regards,
Shyam