Skip to Content

Path of file.

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2014 at 05: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 03, 2014 at 05:51 PM

    Hi Ronaldo,

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

    Arivazhagan S

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 04, 2014 at 03: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 04, 2014 at 04: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.