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: 

Path of file.

ronaldo_aparecido
Contributor
0 Kudos

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 .

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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

arivazhagan_sivasamy
Active Contributor
0 Kudos

Hi Ronaldo,

Instead of giving path name, you can ask user select the path using F4 help.

Arivazhagan S

former_member209120
Active Contributor
0 Kudos

Hi Ronaldo Aparecido

Try like this

DATAi_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.

former_member207661
Active Participant
0 Kudos

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